[IronPython] IronPython and file descriptors

Curt Hagenlocher curt at hagenlocher.org
Mon Dec 15 20:32:03 CET 2008


I guess I'm too much of a purist when it comes to managed code.  But it
would make me sad to P/Invoke by default for this purpose, even if "Mono
compatibility" is the only real counterargument I can muster.

On Mon, Dec 15, 2008 at 10:49 AM, Dino Viehland <dinov at microsoft.com> wrote:

> Presumably CPython is linking against msvcrt and is using the C abstraction
> rather than calling the Win32 APIs which return handles directly.
>
> 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.
>
> -----Original Message-----
> From: users-bounces at lists.ironpython.com [mailto:
> users-bounces at lists.ironpython.com] On Behalf Of Slide
> Sent: Monday, December 15, 2008 10:21 AM
> To: Discussion of IronPython
> Subject: Re: [IronPython] IronPython and file descriptors
>
> On Mon, Dec 15, 2008 at 11:18 AM, Tom Wright
> <tom.wright at resolversystems.com> wrote:
> > Agreed. It is certainly possible with some work to get a file descriptor
> and
> > pass it to C code.
> >
> > This is not the problem, however. Ironclad's aim (eventually) is to allow
> > *arbitrary* C extensions  to work with Ironpython without changing the
> > extensions. Ctypes aim is to allow arbitrary C code to be run by python
> > (possibly in other python libraries which you really don't want to
> modify).
> >
> > In CPython .fileno() is a file descriptor and some modules use this fact
> > (specifically PIL) by passing file descriptors as integers into C code. I
> do
> > not know how one can make this code work in IronPython unless .fileno()
> > returns a file descriptor.
> >
> > The game here is not making a particular C library work with IronPython
> by
> > modifying this library but making as many libraries as possible work
> without
> > modification. Of course whether this is worthwhile depends on how many
> > libraries rely on this fact.
> >
> > Sorry - I hope this is a little clearer.
> >
> > Tom
>
>
> How does CPython get the file descriptor for fileno()? Does it just
> return the HANDLE on Windows?
>
> slide
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20081215/8c1364cb/attachment.html>


More information about the Ironpython-users mailing list