MCPcopy Create free account
hub / github.com/fabioz/PyDev.Debugger / patch_args

Function patch_args

_pydev_bundle/pydev_monkey.py:366–589  ·  view source on GitHub ↗

:param list args: Arguments to patch. :param bool is_exec: If it's an exec, the current process will be replaced (this means we have to keep the same ppid).

(args, is_exec=False)

Source from the content-addressed store, hash-verified

364
365
366def patch_args(args, is_exec=False):
367 """
368 :param list args:
369 Arguments to patch.
370
371 :param bool is_exec:
372 If it's an exec, the current process will be replaced (this means we have
373 to keep the same ppid).
374 """
375 try:
376 pydev_log.debug("Patching args: %s", args)
377 original_args = args
378 try:
379 unquoted_args = remove_quotes_from_args(args)
380 except InvalidTypeInArgsException as e:
381 pydev_log.info("Unable to monkey-patch subprocess arguments because a type found in the args is invalid: %s", e)
382 return original_args
383
384 # Internally we should reference original_args (if we want to return them) or unquoted_args
385 # to add to the list which will be then quoted in the end.
386 del args
387
388 from pydevd import SetupHolder
389
390 if not unquoted_args:
391 return original_args
392
393 if not is_python(unquoted_args[0]):
394 pydev_log.debug("Process is not python, returning.")
395 return original_args
396
397 # Note: we create a copy as string to help with analyzing the arguments, but
398 # the final list should have items from the unquoted_args as they were initially.
399 args_as_str = _get_str_type_compatible("", unquoted_args)
400
401 params_with_value_in_separate_arg = (
402 "--check-hash-based-pycs",
403 "--jit", # pypy option
404 )
405
406 # All short switches may be combined together. The ones below require a value and the
407 # value itself may be embedded in the arg.
408 #
409 # i.e.: Python accepts things as:
410 #
411 # python -OQold -qmtest
412 #
413 # Which is the same as:
414 #
415 # python -O -Q old -q -m test
416 #
417 # or even:
418 #
419 # python -OQold "-vcimport sys;print(sys)"
420 #
421 # Which is the same as:
422 #
423 # python -O -Q old -v -c "import sys;print(sys)"

Callers 9

patch_arg_str_winFunction · 0.85
new_execlFunction · 0.85
new_execvFunction · 0.85
new_execveFunction · 0.85
new_spawnlFunction · 0.85
new_spawnvFunction · 0.85
new_spawnveFunction · 0.85
new_posix_spawnFunction · 0.85
new_fork_execFunction · 0.85

Calls 12

setup_to_argvFunction · 0.90
remove_quotes_from_argsFunction · 0.85
is_pythonFunction · 0.85
_get_str_type_compatibleFunction · 0.85
_is_managed_argFunction · 0.85
_get_host_portFunction · 0.85
_get_python_c_argsFunction · 0.85
quote_argsFunction · 0.85
infoMethod · 0.80
exceptionMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected