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.

classification
Title: socket makefile objects are not independent
Type: behavior Stage: test needed
Components: Library (Lib) Versions: 3rd party
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: Nosy List: georg.brandl, ondrejj
Priority: normal Keywords:

Created on 2007-06-07 09:50 by ondrejj, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
socktest.py ondrejj, 2007-06-07 09:50 socktest.py
Messages (3)
msg32239 - (view) Author: Jan Ondrej (ondrejj) Date: 2007-06-07 09:50
Running some python 2.4 code on python 2.5 does not work properly. Python documentation for socket library says:

makefile(  	[mode[, bufsize]])
    Return a file object associated with the socket. (File objects are described in 3.9, ``File Objects.'') The file object references a dup()ped version of the socket file descriptor, so the file object and socket object may be closed or garbage-collected independently.

It is true for python 2.4, but not for python 2.5 (at least not one in Fedora 7). Closing socket and then using file descriptor does not work. Here is an example code:

import socket
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.connect(('salstar.sk', 25))
f=s.makefile('rw')
s.shutdown(1)
s.close()
print f.readline()

It writes "220 work.salstar.sk ESMTP Postfix" in python 2.4 but raises an exception for python 2.5:

Traceback (most recent call last):
  File "socktest.py", line 9, in <module>
    print f.readline()
  File "/usr/lib/python2.5/socket.py", line 345, in readline
    data = self._sock.recv(self._rbufsize)
socket.error: (9, 'Bad file descriptor')

Is it a bug of python 2.5 or a bug in documentation?
Or is it Fedora specific? Can somebody test it on other systems?
msg84763 - (view) Author: Jan Ondrej (ondrejj) Date: 2009-03-31 08:30
I can't confirm this bug on Fedora 8 or Fedora 10.
I think it's fixed now and should be closed.
Also tested on ubuntu-hardy without problems.
msg85478 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-04-05 10:52
Closing as "works for me".
History
Date User Action Args
2022-04-11 14:56:24adminsetgithub: 45051
2009-04-05 10:52:54georg.brandlsetstatus: open -> closed

nosy: + georg.brandl
messages: + msg85478

resolution: works for me
2009-03-31 08:30:56ondrejjsetmessages: + msg84763
2009-03-31 00:47:37ajaksu2setstage: test needed
type: behavior
versions: + 3rd party
2007-06-07 09:50:47ondrejjcreate