Skip to content

Commit 009e7b3

Browse files
authored
gh-134064: Fix sys.remote_exec() error checking (#134067)
1 parent fc7f4c3 commit 009e7b3

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Lib/test/test_sys.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2176,6 +2176,13 @@ def test_remote_exec_invalid_pid(self):
21762176
with self.assertRaises(OSError):
21772177
sys.remote_exec(99999, "print('should not run')")
21782178

2179+
def test_remote_exec_invalid_script(self):
2180+
"""Test remote exec with invalid script type"""
2181+
with self.assertRaises(TypeError):
2182+
sys.remote_exec(0, None)
2183+
with self.assertRaises(TypeError):
2184+
sys.remote_exec(0, 123)
2185+
21792186
def test_remote_exec_syntax_error(self):
21802187
"""Test remote exec with syntax error in script"""
21812188
script = '''

Python/sysmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2485,7 +2485,7 @@ sys_remote_exec_impl(PyObject *module, int pid, PyObject *script)
24852485
PyObject *path;
24862486
const char *debugger_script_path;
24872487

2488-
if (PyUnicode_FSConverter(script, &path) < 0) {
2488+
if (PyUnicode_FSConverter(script, &path) == 0) {
24892489
return NULL;
24902490
}
24912491
debugger_script_path = PyBytes_AS_STRING(path);

0 commit comments

Comments
 (0)