New submission from STINNER Victor <victor.stin...@haypocalc.com>:

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.

----------
components: IO
messages: 125253
nosy: haypo, pitrou
priority: normal
severity: normal
status: open
title: ValueError on repr(closed_socket_file)
versions: Python 3.2

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue10819>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to