Skip to content

Commit 3a5f004

Browse files
committed
windows fix
1 parent 2ab5d70 commit 3a5f004

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

Python/ceval_gil.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1216,7 +1216,18 @@ static inline void run_remote_debugger_script(const char *path)
12161216
PyErr_FormatUnraisable("Can't find fd for debugger script %s", path);
12171217
} else {
12181218
#ifdef MS_WINDOWS
1219-
FILE* f = _fdopen(fd, "r");
1219+
PyObject* path_obj = PyUnicode_FromString(path);
1220+
if (!path_obj) {
1221+
PyErr_FormatUnraisable("Error when converting remote debugger script path %s to Unicode", path);
1222+
return;
1223+
}
1224+
wchar_t* wpath = PyUnicode_AsWideCharString(path_obj, NULL);
1225+
Py_DECREF(path_obj);
1226+
if (!wpath) {
1227+
PyErr_FormatUnraisable("Error when converting remote debugger script path %s to wide char", path);
1228+
return;
1229+
}
1230+
FILE* f = _wfopen(wpath, L"r");
12201231
#else
12211232
FILE* f = fdopen(fd, "r");
12221233
#endif
@@ -1226,6 +1237,11 @@ static inline void run_remote_debugger_script(const char *path)
12261237
PyRun_AnyFile(f, path);
12271238
}
12281239

1240+
#ifdef MS_WINDOWS
1241+
PyMem_Free(wpath);
1242+
fclose(f);
1243+
#endif
1244+
12291245
if (PyErr_Occurred()) {
12301246
PyErr_FormatUnraisable("Error executing debugger script %s", path);
12311247
}

0 commit comments

Comments
 (0)