Message32239
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? |
|
Date |
User |
Action |
Args |
2007-08-23 14:54:41 | admin | link | issue1732662 messages |
2007-08-23 14:54:41 | admin | create | |
|