[NumPy-Tickets] [NumPy] #1583: fromfile/tofile py3k errors on Windows

NumPy Trac numpy-tickets@scipy....
Mon Aug 23 21:34:27 CDT 2010

#1583: fromfile/tofile py3k errors on Windows
 Reporter:  rgommers                |       Owner:  somebody
     Type:  defect                  |      Status:  new     
 Priority:  high                    |   Milestone:  1.5.0   
Component:  numpy.core              |     Version:  devel   
 Keywords:  fromfile, tofile, py3k  |  

Comment(by cgohlke):

 Using osfhandle did not work for mingw. Same failures. Seems that it's not
 a crt issue. For the records, in the npy_PyFile_Dup function in
 npy_3kcompat.h I tried (error handling omitted):


 PyObject_CallMethod(file, "flush", "");

 /* get osfhandle using Python/msvcrt90 */
 fd = PyObject_AsFileDescriptor(file);
 msvcrt = PyImport_ImportModule("msvcrt");
 ret = PyObject_CallMethod(msvcrt, "get_osfhandle", "i", fd);
 fh = PyNumber_AsSsize_t(ret, 0);

 /* get FILE* from osfhandle using mingw/msvcrt */
 fd2 = _open_osfhandle(fh, 0); /* TODO: second parameter should match mode
 return fdopen(fd2, mode);


 This code works with msvc9 (aside from the TODO).

Ticket URL: <http://projects.scipy.org/numpy/ticket/1583#comment:3>
NumPy <http://projects.scipy.org/numpy>
My example project

More information about the NumPy-Tickets mailing list