main
main copied to clipboard
fileno() on files is not a real file descriptor
Rather than being a real file descriptor fileno() seems to return an identifier for PythonFiles - this means that open files cannot be shared between IronPython and pure C code easily. It would be good if fileno were to return a real file descriptor.
Work Item Details
Original CodePlex Issue: Issue 20242 Status: Active Reason Closed: Unassigned Assigned to: Unassigned Reported on: Dec 15, 2008 at 3:52 PM Reported by: tatwright Updated on: Feb 22, 2013 at 2:14 AM Updated by: fwereade
On 2008-12-16 05:56:18 UTC, fuzzyman commented:
Discussion from the mailing list about this issue:
(Dino) As Curt said the biggest problem for us is that .NET does not expose C file descriptors. Therefore we could fix this by P/Invoking out to msvcrt. For users on other platforms we'd need to either add support for their platform or hope that their handles == C runtime file descriptors. For something like fileno maybe this is ok because it's an interop point only - or are there any non-interop uses of fileno in the world?
What do people think of this? This would be the 1st place where we would add a P/Invoke so I'd want to tread lightly and make sure this is really the right thing to do.
(Michael Foord) Well, some way of doing this is needed if certain Python C extensions are to work with Ironclad. Perhaps a global or per engine setting that allows file handles to be associated with a C descriptor. Users of Ironclad could switch it on if they wished and take the consequences.
(Dino) Can you open a feature request on CodePlex? It's certainly an interesting idea to ponder and I'm leaning towards it but there's lots of details to be gotten right.
Do you know if this needs to work w/ sockets as well? (There's also the question of can we make it work with sockets? :))
There'll be a bunch of places we need to update (nt, socket, file, select, etc...) so I think it'll have to wait until 2.1 instead of coming in a minor update like 2.0.1.
On 2009-07-23 22:53:07 UTC, fwereade commented:
As of Ironclad 0.8.5, this is a much smaller deal: ironclad.patch_native_filenos() does everything we need to work with mmap and PIL.