[patch] Do not open Python scripts twice #2 [Re: [RFC] Crash sourcing Python script on Windows]

Pedro Alves palves@redhat.com
Mon Jan 23 19:57:00 GMT 2012


Does anyone know if there's a way to create a PyFile from an open Windows
file HANDLE (that is, an hypothetical PyFile_from_HANDLE function)?

If there is, we could do something like:

 static PyObject *
 PyFile_from_FILE (FILE *file, const char *filename, char *mode)
 {
 #ifdef _WIN32
   HANDLE h = _get_osfhandle (fileno (file));
   return PyFile_from_HANDLE (h, ...);
 #else
   return PyFile_FromFile(file, filename, mode, ...);
 }

Unlike libc objects, HANDLEs are common to all loaded libcs, given
that they live in the common Win32/NT layer beneath libc, so that
would work around the multiple libc's problem, and, would plug the
race on Windows too.

_get_osfhandle:
http://msdn.microsoft.com/en-us/library/ks2530z6.aspx

-- 
Pedro Alves



More information about the Gdb-patches mailing list