File tree Expand file tree Collapse file tree 1 file changed +16
-17
lines changed
Expand file tree Collapse file tree 1 file changed +16
-17
lines changed Original file line number Diff line number Diff line change @@ -1215,33 +1215,32 @@ static inline void run_remote_debugger_script(const char *path)
12151215 if (fd == -1 ) {
12161216 PyErr_FormatUnraisable ("Can't find fd for debugger script %s" , path );
12171217 } else {
1218+ int dup_fd = -1 ;
1219+ FILE * f = NULL ;
1220+
12181221#ifdef MS_WINDOWS
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 ;
1222+ dup_fd = _dup (fd );
1223+ if (dup_fd != -1 ) {
1224+ f = _fdopen (dup_fd , "r" );
12231225 }
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 ;
1226+ if (!f ) {
1227+ _close (dup_fd );
12291228 }
1230- FILE * f = _wfopen (wpath , L"r" );
12311229#else
1232- FILE * f = fdopen (fd , "r" );
1230+ dup_fd = dup (fd );
1231+ if (dup_fd != -1 ) {
1232+ f = fdopen (fd , "r" );
1233+ }
1234+ if (!f ) {
1235+ close (dup_fd );
1236+ }
12331237#endif
12341238 if (!f ) {
12351239 PyErr_SetFromErrno (PyExc_OSError );
12361240 } else {
1237- PyRun_AnyFile (f , path );
1241+ PyRun_AnyFileEx (f , path , 1 );
12381242 }
12391243
1240- #ifdef MS_WINDOWS
1241- PyMem_Free (wpath );
1242- fclose (f );
1243- #endif
1244-
12451244 if (PyErr_Occurred ()) {
12461245 PyErr_FormatUnraisable ("Error executing debugger script %s" , path );
12471246 }
You can’t perform that action at this time.
0 commit comments