Skip to content

Commit 997b557

Browse files
committed
Use _fdopen to open the debugger script on Windows
This avoids the need to reopen it by (wide character) path.
1 parent a98898d commit 997b557

1 file changed

Lines changed: 3 additions & 19 deletions

File tree

Python/ceval_gil.c

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,25 +1211,14 @@ static inline void run_remote_debugger_script(const char *path)
12111211
return;
12121212
}
12131213

1214-
#ifdef MS_WINDOWS
1215-
PyObject* path_obj = PyUnicode_FromString(path);
1216-
if (!path_obj) {
1217-
PyErr_FormatUnraisable("Error when converting remote debugger script path %s to Unicode", path);
1218-
return;
1219-
}
1220-
wchar_t* wpath = PyUnicode_AsWideCharString(path_obj, NULL);
1221-
Py_DECREF(path_obj);
1222-
if (!wpath) {
1223-
PyErr_FormatUnraisable("Error when converting remote debugger script path %s to wide char", path);
1224-
return;
1225-
}
1226-
FILE* f = _wfopen(wpath, L"r");
1227-
#else
12281214
int fd = PyObject_AsFileDescriptor(fileobj);
12291215
if (fd == -1) {
12301216
PyErr_FormatUnraisable("Error when getting file descriptor for debugger script %s", path);
12311217
return;
12321218
}
1219+
#ifdef MS_WINDOWS
1220+
FILE* f = _fdopen(fd, "r");
1221+
#else
12331222
FILE* f = fdopen(fd, "r");
12341223
#endif
12351224

@@ -1239,11 +1228,6 @@ static inline void run_remote_debugger_script(const char *path)
12391228
PyRun_AnyFile(f, path);
12401229
}
12411230

1242-
#ifdef MS_WINDOWS
1243-
PyMem_Free(wpath);
1244-
fclose(f);
1245-
#endif
1246-
12471231
if (PyErr_Occurred()) {
12481232
PyErr_FormatUnraisable("Error executing debugger script %s", path);
12491233
}

0 commit comments

Comments
 (0)