eric6/DebugClients/Python/DebugUtilities.py

changeset 7895
554fdb07c856
parent 7892
bd6b9e401166
child 7900
72b88fb20261
equal deleted inserted replaced
7894:4370a8b30648 7895:554fdb07c856
314 args.insert(0, sys.executable) 314 args.insert(0, sys.executable)
315 elif isWindowsPlatform() and args[0].lower().endswith(".py"): 315 elif isWindowsPlatform() and args[0].lower().endswith(".py"):
316 # it is a Python script; insert our interpreter as first argument 316 # it is a Python script; insert our interpreter as first argument
317 args.insert(0, sys.executable) 317 args.insert(0, sys.executable)
318 318
319 # check for -m invocation => debugging not supported yet
320 if "-m" in args:
321 cm_position = args.index("-m")
322 else:
323 cm_position = 0
324 if cm_position > 0:
325 # check if it belongs to the interpreter or program
326 for pos in range(1, len(args)):
327 if not args[pos].startswith("-"):
328 # first argument not starting with '-' is the program
329 found = True
330 break
331 else:
332 found = False
333 if found and cm_position < pos:
334 # it belongs to the interpreter
335 return quoteArgs(arguments)
336
337 # extract list of interpreter arguments, i.e. all arguments before the 319 # extract list of interpreter arguments, i.e. all arguments before the
338 # first one not starting with '-'. 320 # first one not starting with '-'.
339 interpreter = args.pop(0) 321 interpreter = args.pop(0)
340 interpreterArgs = [] 322 interpreterArgs = []
341 hasCode = False 323 hasCode = False
324 hasScriptModule = False
342 while args: 325 while args:
343 if args[0].startswith("-"): 326 if args[0].startswith("-"):
344 if args[0] in ("-W", "-X"): 327 if args[0] in ("-W", "-X"):
345 # take two elements off the list 328 # take two elements off the list
346 interpreterArgs.append(args.pop(0)) 329 interpreterArgs.append(args.pop(0))
348 elif args[0] == "-c": 331 elif args[0] == "-c":
349 # -c indicates code to be executed and ends the 332 # -c indicates code to be executed and ends the
350 # arguments list 333 # arguments list
351 args.pop(0) 334 args.pop(0)
352 hasCode = True 335 hasCode = True
336 break
337 elif args[0] == "-m":
338 # -m indicates a module to be executed as a script
339 # and ends the arguments list
340 args.pop(0)
341 hasScriptModule = True
353 break 342 break
354 else: 343 else:
355 interpreterArgs.append(args.pop(0)) 344 interpreterArgs.append(args.pop(0))
356 else: 345 else:
357 break 346 break
380 modifiedArguments.append("--no-encoding") 369 modifiedArguments.append("--no-encoding")
381 if debugClient.multiprocessSupport: 370 if debugClient.multiprocessSupport:
382 modifiedArguments.append("--multiprocess") 371 modifiedArguments.append("--multiprocess")
383 if hasCode: 372 if hasCode:
384 modifiedArguments.append("--code") 373 modifiedArguments.append("--code")
374 modifiedArguments.append(args.pop(0))
375 if hasScriptModule:
376 modifiedArguments.append("--module")
377 modifiedArguments.append(args.pop(0))
385 modifiedArguments.append("--") 378 modifiedArguments.append("--")
386 # end the arguments for DebugClient 379 # end the arguments for DebugClient
387 380
388 # append the arguments for the program to be debugged 381 # append the arguments for the program to be debugged
389 modifiedArguments.extend(args) 382 modifiedArguments.extend(args)

eric ide

mercurial