8000 gh-133886: Fix sys.remote_exec() for non-UTF-8 paths by serhiy-storchaka · Pull Request #133887 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-133886: Fix sys.remote_exec() for non-UTF-8 paths #133887

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Use "goto error:.
  • Loading branch information
serhiy-storchaka committed May 12, 2025
commit f8be85f0c1745799f7f30b8feb73452e9ab6a572
19 changes: 9 additions & 10 deletions Python/sysmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -2491,15 +2491,13 @@ sys_remote_exec_impl(PyObject *module, int pid, PyObject *script)
#ifdef MS_WINDOWS
PyObject *unicode_path;
if (PyUnicode_FSDecoder(path, &unicode_path) < 0) {
Py_DECREF(path);
return NULL;
goto error;
}
// Use UTF-16 (wide char) version of the path for permission checks
wchar_t *debugger_script_path_w = PyUnicode_AsWideCharString(unicode_path, NULL);
Py_DECREF(unicode_path);
if (debugger_script_path_w == NULL) {
Py_DECREF(path);
return NULL;
goto error;
}
DWORD attr = GetFileAttributesW(debugger_script_path_w);
if (attr == INVALID_FILE_ATTRIBUTES) {
Expand All @@ -2514,8 +2512,7 @@ sys_remote_exec_impl(PyObject *module, int pid, PyObject *script)
else {
PyErr_SetFromWindowsErr(err);
}
Py_DECREF(path);
return NULL;
goto error;
}
PyMem_Free(debugger_script_path_w);
#else // MS_WINDOWS
Expand All @@ -2530,17 +2527,19 @@ sys_remote_exec_impl(PyObject *module, int pid, PyObject *script)
default:
PyErr_SetFromErrno(PyExc_OSError);
}
Py_DECREF(path);
return NULL;
goto error;
}
#endif // MS_WINDOWS
if (_PySysRemoteDebug_SendExec(pid, 0, debugger_script_path) < 0) {
Py_DECREF(path);
return NULL;
goto error;
}

Py_DECREF(path);
Py_RETURN_NONE;

error:
Py_DECREF(path);
return NULL;
}


Expand Down
Loading
0