Message348390
I find this new behavior a usability regression. Before this change, code
(e.g python 2 code ported to python 3) could do:
fd = sock.fileno()
Without handling errors, since closed socket would raise (good). Now such code need to check the return value (bad):
fd = sock.fileno()
if fd == -1:
fail...
This is also not consistent with other objects:
>>> f = open("Makefile")
>>> f.fileno()
3
>>> f.close()
>>> f.fileno()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: I/O operation on closed file
>>> repr(f)
"<_io.TextIOWrapper name='Makefile' mode='r' encoding='UTF-8'>"
The issue with repr() on closed socket can be mitigated easily inside __repr__, handling closed sockets without affecting code using file descriptors.
Can we return the old safe behavior? |
|
Date |
User |
Action |
Args |
2019-07-24 15:16:38 | nirs | set | recipients:
+ nirs, pitrou, vstinner |
2019-07-24 15:16:38 | nirs | set | messageid: <1563981398.48.0.836946844582.issue10819@roundup.psfhosted.org> |
2019-07-24 15:16:38 | nirs | link | issue10819 messages |
2019-07-24 15:16:38 | nirs | create | |
|