[New-bugs-announce] [issue23214] BufferedReader.read1(size) signature incompatible with BufferedIOBase.read1(size=-1)

Martin Panter report at bugs.python.org
Sat Jan 10 02:46:22 CET 2015


New submission from Martin Panter:

I am trying to make LZMAFile (which implements BufferedIOBase) use a BufferedReader in read mode. However this broke test_lzma.FileTestCase.test_read1_multistream(), which calls read1() with the default size argument. This is because BufferedReader.read1() does not accept size=-1:

>>> stdin = open(0, "rb", closefd=False)
>>> stdin
<_io.BufferedReader name=0>
>>> stdin.read1()  # Parameter is mandatory
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: read1() takes exactly 1 argument (0 given)
>>> stdin.read1(-1)  # Does not accept the BufferedIOBase default
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: read length must be positive
>>> stdin.read1(0)  # Technically not positive
b''

Also, the BufferedIOBase documentation does not say what the size=-1 value means, only that it reads and returns up to -1 bytes.

----------
components: IO
messages: 233794
nosy: vadmium
priority: normal
severity: normal
status: open
title: BufferedReader.read1(size) signature incompatible with BufferedIOBase.read1(size=-1)
versions: Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23214>
_______________________________________


More information about the New-bugs-announce mailing list