mmap problem with dll
howard at eegsoftware.com
howard at eegsoftware.com
Tue Dec 12 13:29:35 EST 2000
I am trying to back the mmapmodule.cpp into 1.5.2.
I know I know but, I am using PIL,Pmw,Blt,Imaging,Numeric, and serial
and have NOT been able to find a working combination under 2.0
After changing the few error message outputs back to some compatible
format, I can build a DLL containing the modified mmapmodule (using a
new name of course).
However, it doesn't work.
I get the message
EnvironmentError: [Errno 2] No such file or directory
on the mmap object creation call.
I traced it back to the _get_osfhandle call trying to get the
operating system equivalent of the run-time library handle.
So, I rebuilt the dll to use the Python 2.0 includes and tried it
under 2.0. It still doesn't work. The built-in mmap DOES work.
In the dll, I printed out the result from _get_osfhandle....sure
enough it returned -1. In the Python code, I printed out
msvcrt.get_osfhandle and it works correctly.
My test code (fragment):
hfile=win32file.CreateFile( filename,\
win32con.GENERIC_READ|win32con.GENERIC_WRITE,\
win32con.FILE_SHARE_READ|win32con.FILE_SHARE_WRITE,\
secur_att,\
win32con.OPEN_ALWAYS,\
win32con.FILE_ATTRIBUTE_NORMAL , 0 )
rslt=win32api.GetLastError()
if rslt == 0:
# here if file was CREATED
#mmap to this file
fd=msvcrt.open_osfhandle(hfile.handle,0)
if mstyle == 20:
map=mmap.mmap(fd,self.filesize)
else:
map=mmapnew.mmap(fd,self.filesize)
# other stuff
elif rslt == winerror.ERROR_ALREADY_EXISTS:
# here if it already existed
#mmap to this file
fd=msvcrt.open_osfhandle(hfile.handle,0)
print hfile.handle,fd,msvcrt.get_osfhandle(fd)
if mstyle== 20:
map=mmap.mmap(fd,filesize)
else:
map=mmapnew.mmap(fd,filesize)
# other stuff
else:
print 'Some other error',rslt
Any clues on why the dll version won't get back a correct os file
handle?
Thanks
Howard Lightstone
EEGSoftware
howard at eegsoftware.com
More information about the Python-list
mailing list