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.

Author nirs
Recipients nirs, pitrou, vstinner
Date 2019-07-24.15:16:38
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1563981398.48.0.836946844582.issue10819@roundup.psfhosted.org>
In-reply-to
Content
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?
History
Date User Action Args
2019-07-24 15:16:38nirssetrecipients: + nirs, pitrou, vstinner
2019-07-24 15:16:38nirssetmessageid: <1563981398.48.0.836946844582.issue10819@roundup.psfhosted.org>
2019-07-24 15:16:38nirslinkissue10819 messages
2019-07-24 15:16:38nirscreate