Skip to content

Commit eaee2ae

Browse files
[3.14] gh-134064: Fix sys.remote_exec() error checking (GH-134067) (#134162)
gh-134064: Fix sys.remote_exec() error checking (GH-134067) (cherry picked from commit 009e7b3) Co-authored-by: Victor Stinner <vstinner@python.org>
1 parent 1ba5e65 commit eaee2ae

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
@@ -2484,7 +2484,7 @@ sys_remote_exec_impl(PyObject *module, int pid, PyObject *script)
24842484
PyObject *path;
24852485
const char *debugger_script_path;
24862486

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

0 commit comments

Comments
 (0)