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 vstinner
Recipients pitrou, vstinner
Date 2011-01-03.23:51:31
SpamBayes Score 2.507096e-07
Marked as misclassified No
Message-id <1294098693.54.0.480300363848.issue10819@psf.upfronthosting.co.za>
In-reply-to
Content
The following code raise a ValueError('I/O operation on closed file.'):
---
import socket
socket.socket(socket.SOCK_STREAM, socket.AF_INET)
s=socket.socket(socket.SOCK_STREAM, socket.AF_INET)
f=s.makefile("rb")
f.close()
print(repr(f))
---

io.BufferedReader.__repr__() reads self.name (self.buffer.name), but self.buffer is closed.

io.BufferedReader.__repr__() catchs AttributeError when reading self.name. It should also maybe catch ValueError: attached patch does that.

socket.repr(x) returns a string with "[closed]". BufferedReader.repr() should maybe do the same.

Note: TextIOWrapper has the same issue.
History
Date User Action Args
2011-01-03 23:51:33vstinnersetrecipients: + vstinner, pitrou
2011-01-03 23:51:33vstinnersetmessageid: <1294098693.54.0.480300363848.issue10819@psf.upfronthosting.co.za>
2011-01-03 23:51:31vstinnerlinkissue10819 messages
2011-01-03 23:51:31vstinnercreate