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.

classification
Title: BufferedReader.read1 does not check for closed file
Type: Stage:
Components: Versions:
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, pitrou, sandro.tosi
Priority: normal Keywords:

Created on 2010-10-28 11:43 by amaury.forgeotdarc, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (3)
msg119771 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2010-10-28 11:43
The following snippet should raise ValueError (twice :-)

f = open('foo', 'rb')
print(f.read1(1)) # OK
f.close()
print(f.read1(5)) # expected ValueError("I/O operation on closed file")
print(f.peek())   # expected ValueError("I/O operation on closed file")

The _pyio implementation of BufferedReader.read() has the same issue.
msg132600 - (view) Author: Sandro Tosi (sandro.tosi) * (Python committer) Date: 2011-03-30 18:24
Hi,
on a freshly built python 3.3 I got:

$ ./python 
Python 3.3a0 (default:22ae2b002865, Mar 30 2011, 20:18:39) 
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> f = open('foo', 'rb')
>>> print(f.read1(1)) # OK
b''
>>> f.close()
>>> print(f.read1(5)) # expected ValueError("I/O operation on closed file")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: I/O operation on closed file
>>> print(f.peek())   # expected ValueError("I/O operation on closed file")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: I/O operation on closed file
>>> 

so it seems it's been fixed in the meantime. Do you have an example for BufferedReader?
msg132616 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2011-03-30 21:46
Indeed, I can't reproduce the issue anymore
History
Date User Action Args
2022-04-11 14:57:08adminsetgithub: 54428
2011-03-30 21:46:59amaury.forgeotdarcsetstatus: open -> closed
resolution: out of date
messages: + msg132616
2011-03-30 18:24:46sandro.tosisetnosy: + sandro.tosi
messages: + msg132600
2010-10-28 11:43:16amaury.forgeotdarccreate