Nir Soffer <[email protected]> added the comment:
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?
----------
nosy: +nirs
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue10819>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com