Re: How to create a socket.socket() object from a socket fd?

2017-01-23 Thread Ethan Furman
On 01/23/2017 09:00 AM, Grant Edwards wrote: On 2017-01-23, Antoon Pardon wrote: The standard response to issues like this is: A foolish consistency is the hobgoblin of little minds And wise consistency is the foundation of a good language design. Otherwise known as: if there's not a

Re: How to create a socket.socket() object from a socket fd?

2017-01-23 Thread Grant Edwards
On 2017-01-23, Antoon Pardon wrote: > Op 22-01-17 om 01:52 schreef Grant Edwards: >> Newsgroups: gmane.comp.python.general >> From: Grant Edwards >> Subject: Re: How to create a socket.socket() object from a socket fd? >> References: >> >> >> Fol

Re: How to create a socket.socket() object from a socket fd?

2017-01-23 Thread Antoon Pardon
Op 22-01-17 om 01:52 schreef Grant Edwards: > Newsgroups: gmane.comp.python.general > From: Grant Edwards > Subject: Re: How to create a socket.socket() object from a socket fd? > References: > > > Followup-To: > > > > I'm still baffled why the sta

Re: How to create a socket.socket() object from a socket fd?

2017-01-22 Thread Christian Heimes
On 2017-01-22 01:03, Grant Edwards wrote: > On 2017-01-21, Christian Heimes wrote: > >> You might be interested in my small module >> https://pypi.python.org/pypi/socketfromfd/ . I just releases a new >> version with a fix for Python 2. Thanks for the hint! :) >> >> The module correctly detects a

Re: How to create a socket.socket() object from a socket fd?

2017-01-21 Thread Grant Edwards
Newsgroups: gmane.comp.python.general From: Grant Edwards Subject: Re: How to create a socket.socket() object from a socket fd? References: Followup-To: I'm still baffled why the standard library fromfd() code dup()s the descriptor. According to the comment in the CPython sources

Re: How to create a socket.socket() object from a socket fd?

2017-01-21 Thread Grant Edwards
On 2017-01-21, Christian Heimes wrote: > You might be interested in my small module > https://pypi.python.org/pypi/socketfromfd/ . I just releases a new > version with a fix for Python 2. Thanks for the hint! :) > > The module correctly detects address family, socket type and proto from > a fd. I

Re: How to create a socket.socket() object from a socket fd?

2017-01-21 Thread Grant Edwards
On 2017-01-21, Chris Angelico wrote: > On Sun, Jan 22, 2017 at 9:41 AM, Grant Edwards > wrote: >> | __init__(self, family=2, type=1, proto=0, _sock=None) >> | >> >> Ah! There's a keyword argument that doesn't appear in the docs, so >> let's try that... > > That's marginally better than my monke

Re: How to create a socket.socket() object from a socket fd?

2017-01-21 Thread Peter Otten
Grant Edwards wrote: > Given a Unix file discriptor for an open TCP socket, I can't figure > out how to create a python 2.7 socket object like those returned by > socket.socket() > > Based on the docs, one might think that socket.fromfd() would do that > (since the docs say that's what it does):

Re: How to create a socket.socket() object from a socket fd?

2017-01-21 Thread Christian Heimes
On 2017-01-21 23:41, Grant Edwards wrote: > On 2017-01-21, Grant Edwards wrote: > >> Given a Unix file discriptor for an open TCP socket, I can't figure >> out how to create a python 2.7 socket object like those returned by >> socket.socket() >> >> Based on the docs, one might think that socket.f

Re: How to create a socket.socket() object from a socket fd?

2017-01-21 Thread Chris Angelico
On Sun, Jan 22, 2017 at 9:41 AM, Grant Edwards wrote: > | __init__(self, family=2, type=1, proto=0, _sock=None) > | > > Ah! There's a keyword argument that doesn't appear in the docs, so > let's try that... That's marginally better than my monkeypatch-after-creation suggestion, but still broad

Re: How to create a socket.socket() object from a socket fd?

2017-01-21 Thread Grant Edwards
On 2017-01-21, Grant Edwards wrote: > Given a Unix file discriptor for an open TCP socket, I can't figure > out how to create a python 2.7 socket object like those returned by > socket.socket() > > Based on the docs, one might think that socket.fromfd() would do that > (since the docs say that's

Re: How to create a socket.socket() object from a socket fd?

2017-01-21 Thread Chris Angelico
On Sun, Jan 22, 2017 at 9:28 AM, Grant Edwards wrote: > Given a Unix file discriptor for an open TCP socket, I can't figure > out how to create a python 2.7 socket object like those returned by > socket.socket() I suspect you can't easily do it. In more recent Pythons, you can socket.socket(filen

How to create a socket.socket() object from a socket fd?

2017-01-21 Thread Grant Edwards
Given a Unix file discriptor for an open TCP socket, I can't figure out how to create a python 2.7 socket object like those returned by socket.socket() Based on the docs, one might think that socket.fromfd() would do that (since the docs say that's what it does): Quoting https://docs.python.org/