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 martin.panter
Recipients martin.panter
Date 2015-03-28.00:29:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
If the BufferedReader object has already been closed, calling peek() can cause a strange error message or a crash:

$ python3 -bWall
Python 3.4.2 (default, Oct  8 2014, 14:33:30) 
[GCC 4.9.1 20140903 (prerelease)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from io import *
>>> b = BufferedReader(BytesIO())
>>> b.close()
>>> b.peek()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: PyMemoryView_FromBuffer(): info->buf must not be NULL
>>> b = BufferedReader(BytesIO(b"12"))
>>> b.close()
>>> b.peek()
Segmentation fault (core dumped)
[Exit 139]

I’m not able to check with 3.5 at the moment, but looking at the code, I suspect this also applies to 3.5 and there needs to be a CHECK_CLOSED() call added somewhere around Modules/_io/bufferedio.c:884.
Date User Action Args
2015-03-28 00:29:50martin.pantersetrecipients: + martin.panter
2015-03-28 00:29:50martin.pantersetmessageid: <>
2015-03-28 00:29:49martin.panterlinkissue23796 messages
2015-03-28 00:29:49martin.pantercreate