PY-37311 Patch interpreter command for Python 2

IJ-CR-26283

GitOrigin-RevId: 24575b5177831685d56f66c5546800c66553bd19
This commit is contained in:
Egor Eliseev
2022-09-07 12:39:17 +00:00
committed by intellij-monorepo-bot
parent 6b52116a24
commit 7ec061b418
4 changed files with 49 additions and 3 deletions
@@ -451,7 +451,6 @@ def create_execl(original_name):
import os
args = patch_args(args)
if is_python_args(args):
path = args[0]
send_process_will_be_substituted()
return getattr(os, original_name)(path, *args)
return new_execl
@@ -466,7 +465,6 @@ def create_execv(original_name):
import os
args = patch_args(args)
if is_python_args(args):
path = args[0]
send_process_will_be_substituted()
return getattr(os, original_name)(path, args)
return new_execv
@@ -481,7 +479,6 @@ def create_execve(original_name):
import os
args = patch_args(args)
if is_python_args(args):
path = args[0]
send_process_will_be_substituted()
return getattr(os, original_name)(path, args, env)
return new_execve
@@ -0,0 +1,5 @@
import os
import sys
args = ['python', 'test4.py']
os.execv(sys.executable, args)
@@ -0,0 +1,3 @@
import subprocess
subprocess.call(['python', '-V'])
@@ -239,4 +239,45 @@ public class PythonDebuggerMultiprocessingTest extends PyEnvTestCase {
}
});
}
@Test
public void testCallExecWithPythonArg() {
runPythonTest(new PyDebuggerTask("/debug", "test_call_exec_with_python_arg.py") {
@Override
protected void init() {
setMultiprocessDebug(true);
}
@Override
public void before() {
toggleBreakpoint(getFilePath("test4.py"), 1);
}
@Override
public void testing() throws Exception {
waitForPause();
setProcessCanTerminate(true);
resume();
waitForOutput("3");
}
@Override
public @NotNull Set<String> getTags() {
return Collections.singleton("python2.7");
}
});
runPythonTest(new PyDebuggerTask("/debug", "test_call_python_version.py") {
@Override
public void testing() throws Exception {
waitForTerminate();
outputContains("Python");
}
@Override
public @NotNull Set<String> getTags() {
return Collections.singleton("python2.7");
}
});
}
}