IDEA-CR-56419: PY-34555 Clean module flag for child process

If a process was started with `-m` key (and converted to `--module` flag), this parameter will be passed to all its child processes. So we need to clear this flag in SetupHolder before patching arguments

GitOrigin-RevId: 00ae0b23fc6107bee75272a03a5bd15ca474fbc7
This commit is contained in:
Elizaveta Shashkova
2019-11-28 16:00:38 +03:00
committed by intellij-monorepo-bot
parent a0ee74c04e
commit 5c67bc0373
3 changed files with 28 additions and 0 deletions

View File

@@ -228,6 +228,7 @@ def patch_args(args):
# ['X:\\pysrc\\pydevd.py', '--multiprocess', '--print-in-debugger-startup',
# '--vm_type', 'python', '--client', '127.0.0.1', '--port', '56352', '--file', 'x:\\snippet1.py']
from _pydevd_bundle.pydevd_command_line_handling import setup_to_argv
SetupHolder.setup['module'] = False # clean module param from parent process
original = setup_to_argv(SetupHolder.setup) + ['--file']
while i < len(args):
if args[i] == '-m':

View File

@@ -0,0 +1,8 @@
from __future__ import print_function
import os
import subprocess
import sys
ret = subprocess.call([os.path.abspath(sys.executable), "-m", "test_subprocess"])
print("Module returned code %d" % ret)

View File

@@ -194,4 +194,23 @@ public class PythonDebuggerMultiprocessingTest extends PyEnvTestCase {
}
});
}
@Test
public void testSubprocessModule() {
runPythonTest(new PyDebuggerMultiprocessTask("/debug", "test_subprocess_module.py") {
@Override
public void before() {
toggleBreakpoint(getFilePath("test_python_subprocess_another_helper.py"), 2);
setWaitForTermination(false);
}
@Override
public void testing() throws Exception {
waitForPause();
eval("x").hasValue("42");
resume();
waitForOutput("Module returned code 0");
}
});
}
}