: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)
| 364 | |
| 365 | |
| 366 | def 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)" |
no test coverage detected