[issue27377] Add smarter socket.fromfd()

2017-04-28 Thread Neil Schemenauer
Changes by Neil Schemenauer : -- pull_requests: +1460 ___ Python tracker ___ ___

[issue27377] Add smarter socket.fromfd()

2017-04-27 Thread Neil Schemenauer
Changes by Neil Schemenauer : -- pull_requests: +1441 ___ Python tracker ___ ___

[issue27377] Add smarter socket.fromfd()

2016-09-15 Thread Christian Heimes
Christian Heimes added the comment: I opened #28134 because I was running into a similar issue with socket.socket(fileno). Since this new feature didn't make it into 3.6, can we at least change the constructor of socket.socket() to set a correct family, type and proto? Any fix is better than

[issue27377] Add smarter socket.fromfd()

2016-07-17 Thread Martin Panter
Martin Panter added the comment: The Windows problem, error 10022 = WSAEINVAL from getsockname(), seems to be documented at : “The socket has not been bound”. Regarding the SCTP problem, raising an error

[issue27377] Add smarter socket.fromfd()

2016-07-14 Thread Neil Schemenauer
Neil Schemenauer added the comment: Tested on FreeBSD 10.3. getsockname() on a IPPROTO_SCTP protocol socket returns errno = FileNoFoundError. We could just comment out that test I guess. My theory is that on FreeBSD, getsockname() on an SCTP socket fails if it is not bound. Indeed, adding

[issue27377] Add smarter socket.fromfd()

2016-07-14 Thread Neil Schemenauer
Neil Schemenauer added the comment: Updated patch, v5. Disable fdtype() function on Windows. Fix documentation nits as suggested by review of v4. -- Added file: http://bugs.python.org/file43722/fromfd2_v5.txt ___ Python tracker

[issue27377] Add smarter socket.fromfd()

2016-07-14 Thread Neil Schemenauer
Neil Schemenauer added the comment: I just tested on Windows. fdtype() fails with: OSError: [WinError 10022] An invalid argument was supplied The getsockname() call fails with WSAGetLastError() == 10022. getsockname() is used to find the address family. Perhaps there is some other way to

[issue27377] Add smarter socket.fromfd()

2016-07-10 Thread Martin Panter
Martin Panter added the comment: Left some minor code review nitpicks. I opened Issue 27409 with an attempt at documenting exactly which SO_* etc symbols may be available. But so far I haven’t got any positive or negative feedback. If it were up to me, I would either commit everything except

[issue27377] Add smarter socket.fromfd()

2016-07-07 Thread Neil Schemenauer
Neil Schemenauer added the comment: Adding yet another revised patch. I think this is ready to commit, if someone would like to do it. The documentation for constants can be added as a separate commit, if Martin wants. I think the generic SO_* style documentation is okay. Changes in this

[issue27377] Add smarter socket.fromfd()

2016-06-28 Thread Martin Panter
Martin Panter added the comment: The s.detach() thing isn’t a big deal, but I thought it would simplify the code (eliminate the need for the “finally” clause). I will try to propose a minor documentation update for SO_PASSCRED as a starting point for adding the others. --

[issue27377] Add smarter socket.fromfd()

2016-06-28 Thread Neil Schemenauer
Neil Schemenauer added the comment: I've revised the patch based on the second round of comments from Martin. I've removed the ifdef test for CO_TYPE and assumed it is always available. That means fdtype() should be available on all platforms. I did not change the test as suggested to call

[issue27377] Add smarter socket.fromfd()

2016-06-24 Thread Martin Panter
Martin Panter added the comment: Okay, I guess the fdtype() API could be useful if we don’t alter fromfd(), i.e. as a workaround for Issue 18391. IMO the specific SO_* constants should at least be listed in the documentation, so users know which versions of Python have which constants.

[issue27377] Add smarter socket.fromfd()

2016-06-24 Thread Neil Schemenauer
Neil Schemenauer added the comment: Thank you for the excellent review Martin. I'm attaching a new patch which I think addresses your points. I created it from hg, maybe that works nicer. I've added constants for SO_DOMAIN, SO_PROTOCOL, SO_PASSCRED, SO_PEERSEC, and SO_PASSEC. Using

[issue27377] Add smarter socket.fromfd()

2016-06-23 Thread Martin Panter
Martin Panter added the comment: Maybe if the patch was regenerated with Mercurial off a public revision, it would work with Rietveld. I have seen non-Mercurial patches work too though. Perhaps this one doesn’t because the line numbers are off compared to the default branch? See also Issue

[issue27377] Add smarter socket.fromfd()

2016-06-23 Thread SilentGhost
SilentGhost added the comment: The patch applies cleanly, not sure why the rietveld link doesn't appear. Perhaps because of the extension? In test, I noticed, that you're not testing that OSError is raised, perhaps something to add? -- nosy: +SilentGhost

[issue27377] Add smarter socket.fromfd()

2016-06-23 Thread Neil Schemenauer
Changes by Neil Schemenauer : Removed file: http://bugs.python.org/file43523/fromfd2.txt ___ Python tracker ___

[issue27377] Add smarter socket.fromfd()

2016-06-23 Thread Neil Schemenauer
Neil Schemenauer added the comment: Add documentation for new functions. -- Added file: http://bugs.python.org/file43524/fromfd2.txt ___ Python tracker

[issue27377] Add smarter socket.fromfd()

2016-06-23 Thread Neil Schemenauer
New submission from Neil Schemenauer: When implementing server software that inherits a socket via a file descriptor, it is useful to be able to query the descriptor and find out what kind of socket has been passed. This can be done with getsockopt() and getsockname(). Python does not