]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-134064: Fix sys.remote_exec() error checking (#134067)
authorVictor Stinner <vstinner@python.org>
Sat, 17 May 2025 22:24:40 +0000 (18:24 -0400)
committerGitHub <noreply@github.com>
Sat, 17 May 2025 22:24:40 +0000 (00:24 +0200)
Lib/test/test_sys.py
Python/sysmodule.c

index 8af2e3488b48d949456054a873161743c6e1fec3..fb1c8492a64d38f545d6584f1d676194d80fd445 100644 (file)
@@ -2176,6 +2176,13 @@ raise Exception("Remote script exception")
         with self.assertRaises(OSError):
             sys.remote_exec(99999, "print('should not run')")
 
+    def test_remote_exec_invalid_script(self):
+        """Test remote exec with invalid script type"""
+        with self.assertRaises(TypeError):
+            sys.remote_exec(0, None)
+        with self.assertRaises(TypeError):
+            sys.remote_exec(0, 123)
+
     def test_remote_exec_syntax_error(self):
         """Test remote exec with syntax error in script"""
         script = '''
index dd048205757eb1f59e6bbc92547e3511f450d9c1..4ed045e3297bbcc4b21024271886a3322dedea3c 100644 (file)
@@ -2485,7 +2485,7 @@ sys_remote_exec_impl(PyObject *module, int pid, PyObject *script)
     PyObject *path;
     const char *debugger_script_path;
 
-    if (PyUnicode_FSConverter(script, &path) < 0) {
+    if (PyUnicode_FSConverter(script, &path) == 0) {
         return NULL;
     }
     debugger_script_path = PyBytes_AS_STRING(path);