This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author martin.panter
Recipients JoshN, docs@python, josh.r, martin.panter, pitrou
Date 2016-04-07.02:24:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1459995885.51.0.139925107129.issue26703@psf.upfronthosting.co.za>
In-reply-to
Content
Yes, I think this is the expected behaviour, and I can’t think of any improvements that could be made. If you call fileno(), you have to ensure that you don’t close the file descriptor until you have finished using it. It is a bit like accessing memory after it has been freed. Python doesn’t make raw memory addresses easily accessible, but it does make fileno() accessible without much protection.

Perhaps there is some confusion about the term socket. Normally (without using the fileno=... parameter), Python’s socket() constructor does two things. First, it creates a new OS socket using the socket() system call (or Winsock equivalent), which returns a file descriptor or handle (an integer). Then, it creates a Python socket object, which wraps the file descriptor.

When you use socket(fileno=...), only the second step is taken. You get a _new_ socket object, which wraps the given existing OS socket file descriptor. So when it says “the same socket”, I think it means the same OS-level socket. It still creates a new Python object.
History
Date User Action Args
2016-04-07 02:24:45martin.pantersetrecipients: + martin.panter, pitrou, docs@python, josh.r, JoshN
2016-04-07 02:24:45martin.pantersetmessageid: <1459995885.51.0.139925107129.issue26703@psf.upfronthosting.co.za>
2016-04-07 02:24:45martin.panterlinkissue26703 messages
2016-04-07 02:24:44martin.pantercreate