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.

Title: socket object method "makefile" has wrong doc
Type: Stage:
Components: Documentation Versions: Python 2.3
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: skip.montanaro Nosy List: irmen, neunhoef, skip.montanaro
Priority: low Keywords:

Created on 2003-11-03 21:23 by neunhoef, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg18880 - (view) Author: Max Neunhöffer (neunhoef) Date: 2003-11-03 21:23
The documentation of the method "makefile" for socket
objects still claims that the new file object
corresponds to a dup()ped file descriptor, which seems
to be wrong.

Python Version: 2.3.2 
Operating system: Debian GNU/Linux
msg18881 - (view) Author: Irmen de Jong (irmen) (Python triager) Date: 2004-11-07 19:00
Logged In: YES 

Why does this seem to be wrong? 
If I look at the code in socketmodule.c, it seems to me that
sock_makefile does a dup() on the socket's fd, and returns a
file based on the new fd....
msg18882 - (view) Author: Max Neunhöffer (neunhoef) Date: 2004-12-20 10:18
Logged In: YES 

I can no longer understand what made me file this bug
report. I vaguely remember having had the problem that no
dup was done,
but I am no longer sure what I have seen at the time.
Sorry for the inconvenience!
msg18883 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2004-12-20 15:04
Logged In: YES 

I'm pretty sure I know why you filed this item.
contains code to work around shortcomings on Windows and BeOS 
(neither were able to dup() sockets).  At some point we
incorporated that
same code for other platforms for consistency reasons, thus
sockets are not really dup'd:

>>> import socket
>>> s = socket.socket()
>>> s
<socket._socketobject object at 0x81d9dec>
>>> t = s.dup()
>>> t
<socket._socketobject object at 0x81df02c>
>>> t._sock
<socket object, fd=3, family=2, type=2, protocol=0>
>>> s._sock
<socket object, fd=3, family=2, type=2, protocol=0>
>>> id(s._sock)
>>> id(t._sock)

Most of the time this doesn't affect anything, but I believe
it does
in certain cases.
Date User Action Args
2022-04-11 14:56:00adminsetgithub: 39496
2003-11-03 21:23:37neunhoefcreate