[New-bugs-announce] [issue10819] ValueError on repr(closed_socket_file)

STINNER Victor report at bugs.python.org
Tue Jan 4 00:51:33 CET 2011

New submission from STINNER Victor <victor.stinner at 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)

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 <report at bugs.python.org>

More information about the New-bugs-announce mailing list