I am trying to pass a file descriptor through ctypes to a C function where the entries are done on fd. On linux, this works. In windows, this is not so, and I do not understand why (I have no experience working as a developer on windows)
from python (ommites details):
mylib.fun.argtypes = [POINTER(bah), c_int] fh = open(filename,'wb')
the program dies on writing () s with the failed statement _osfile (fh) and FOPEN
cl.exe: 16.00.40219.01 for x86 python 2.7.2 msc v.1500 32bit
how should i do this? No, I do not want to unload open () in lib. I want to transfer an already open file descriptor in a secure manner, regardless of platform.
additional information, just in case: the library is tinycdb, I quickly put it in windows with a short specification of cmake and a few dirty patches to export getopt and dll. the library and the exe tool work as expected (verified). python ctypes shells for tinycdb run on Linux as expected. the windows give me eyeballs. he does not recognize that fd is a valid descriptor, even if I pass it after opening it with my own (msvcrt) _open libcall.
Of course, everything works if I open () ing / close () in a file in the library, but I cannot afford to change the API.
source share