Re: [Python-Dev] PEP 446: issue with sockets

2013-08-21 Thread Richard Oudkerk
On 21/08/2013 1:50pm, Victor Stinner wrote: 2013/8/21 Richard Oudkerk : On 21/08/2013 1:19am, Victor Stinner wrote: I don't know if a socket handle is similar to file handles or if they are specials. At least, GetHandleInformation() and SetHandleInformation() functions, used by os.get/set_handl

Re: [Python-Dev] PEP 446: issue with sockets

2013-08-21 Thread Victor Stinner
2013/8/21 Richard Oudkerk : > On 21/08/2013 1:19am, Victor Stinner wrote: >> I don't know if a socket handle is similar to file handles or if they >> are specials. At least, GetHandleInformation() and >> SetHandleInformation() functions, used by >> os.get/set_handle_inheritable(), accept socket han

Re: [Python-Dev] PEP 446: issue with sockets

2013-08-21 Thread Richard Oudkerk
On 21/08/2013 1:19am, Victor Stinner wrote: 2013/8/21 Guido van Rossum : Also, are you sure the things returned by socket.fleno() are really Windows handles? I thought they were some other artificial namespace used just by sockets. (You know what? I know understand and love the UNIX concept "e

Re: [Python-Dev] PEP 446: issue with sockets

2013-08-20 Thread Victor Stinner
2013/8/21 Guido van Rossum : > Since this is a new API and only applies to sockets, making them methods > sounds good. (I'd put the 'nt' test outside the method defs though so they > are tested only once per import.) I added get_inheritable() and set_inheritable() methods to socket.socket. The nam

Re: [Python-Dev] PEP 446: issue with sockets

2013-08-20 Thread Victor Stinner
2013/8/21 Guido van Rossum : > Also, are you sure the things returned by socket.fleno() are really Windows > handles? I thought they were some other artificial namespace used just by > sockets. (You know what? I know understand and love the UNIX concept "everything is file"!) I don't know if a so

Re: [Python-Dev] PEP 446: issue with sockets

2013-08-20 Thread Guido van Rossum
Since this is a new API and only applies to sockets, making them methods sounds good. (I'd put the 'nt' test outside the method defs though so they are tested only once per import.) On Tue, Aug 20, 2013 at 4:57 PM, Victor Stinner wrote: > 2013/8/21 Victor Stinner : > > Should I add a portable he

Re: [Python-Dev] PEP 446: issue with sockets

2013-08-20 Thread Guido van Rossum
Agreed that guessing whether something's a handle or not is terrible. If this is truly only for sockets then maybe it should live in the socket module? Also, are you sure the things returned by socket.fleno() are really Windows handles? I thought they were some other artificial namespace used just

Re: [Python-Dev] PEP 446: issue with sockets

2013-08-20 Thread Victor Stinner
2013/8/21 Victor Stinner : > Should I add a portable helper to the > socket module (socket.get/set_inheritable)? Add the two following functions to the socket module: def get_inheritable(sock): if os.name == 'nt': return os.get_handle_inheritable(sock.fileno()) else: retur

[Python-Dev] PEP 446: issue with sockets

2013-08-20 Thread Victor Stinner
Hi, I have a new question for my PEP 446 (inheritance of file descriptors). os.get/set_inheritable(handle) has strange behaviour on Windows, and so I would like to add new os.get/set_handle_inheritable() functions to avoid it. The problem is that a socket would require a different function depend