Message239445
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.read(1)
b'1'
>>> 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:50 | martin.panter | set | recipients:
+ martin.panter |
2015-03-28 00:29:50 | martin.panter | set | messageid: <1427502590.02.0.665422119627.issue23796@psf.upfronthosting.co.za> |
2015-03-28 00:29:49 | martin.panter | link | issue23796 messages |
2015-03-28 00:29:49 | martin.panter | create | |
|