How to receive a FILE* from Python under MinGW?
gagsl-py2 at yahoo.com.ar
Wed Mar 21 07:08:23 CET 2007
En Wed, 21 Mar 2007 01:58:05 -0300, John Pye <john.pye at gmail.com> escribió:
> Hmm. Reading this again I think I understand properly now. The
> 'fileno' is really *not* the same thing as the FILE* pointer cast to
> an integer. It is a lower-level structure.
Just an integer. But as Ross Ridge has pointed out, it's not an OS thing
on Windows, it's faked by the C runtime.
> The question is now, if I don't want to modify my *python* code, how
> do I get at the 'fileno' property of my PyFileObject?
From Python, calling the fileno() method. From C, using
And then, using get_osfhandle(fd)
> Also, are there consequences for using this approach of regenerating
> the FILE struct? For example if I have the following:
> F = os.tmpfile()
> F.write("some data")
> S = F.read()
> print S
Just try it and let us know what happens! :)
> I don't know enough about this low-level file handling to really
> understand the implications of what you are proposing -- perhaps you
> could explain a little?
It's too late (for me) now, but if you can't make it work I'll try an
More information about the Python-list