diff options
author | Martin Panter <vadmium+py@gmail.com> | 2016-10-20 23:48:14 (GMT) |
---|---|---|
committer | Martin Panter <vadmium+py@gmail.com> | 2016-10-20 23:48:14 (GMT) |
commit | ccb2c0e31056de091abdd62fc07ca6e4bb052f24 (patch) | |
tree | 84ff95e0152d152124b078a9f6e85f053b7147c1 /Modules/_io/bufferedio.c | |
parent | ea8762cae64813788633b7d2a93c2c513c01fdea (diff) | |
download | cpython-ccb2c0e31056de091abdd62fc07ca6e4bb052f24.zip cpython-ccb2c0e31056de091abdd62fc07ca6e4bb052f24.tar.gz cpython-ccb2c0e31056de091abdd62fc07ca6e4bb052f24.tar.bz2 |
Issue #23214: Implement optional BufferedReader, BytesIO read1() argument
Diffstat (limited to 'Modules/_io/bufferedio.c')
-rw-r--r-- | Modules/_io/bufferedio.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c index cbe7425..c760522 100644 --- a/Modules/_io/bufferedio.c +++ b/Modules/_io/bufferedio.c @@ -904,7 +904,7 @@ _io__Buffered_read_impl(buffered *self, Py_ssize_t n) CHECK_INITIALIZED(self) if (n < -1) { PyErr_SetString(PyExc_ValueError, - "read length must be positive or -1"); + "read length must be non-negative or -1"); return NULL; } @@ -932,22 +932,20 @@ _io__Buffered_read_impl(buffered *self, Py_ssize_t n) /*[clinic input] _io._Buffered.read1 - size as n: Py_ssize_t + size as n: Py_ssize_t = -1 / [clinic start generated code]*/ static PyObject * _io__Buffered_read1_impl(buffered *self, Py_ssize_t n) -/*[clinic end generated code: output=bcc4fb4e54d103a3 input=8d2869c18b983184]*/ +/*[clinic end generated code: output=bcc4fb4e54d103a3 input=7d22de9630b61774]*/ { Py_ssize_t have, r; PyObject *res = NULL; CHECK_INITIALIZED(self) if (n < 0) { - PyErr_SetString(PyExc_ValueError, - "read length must be positive"); - return NULL; + n = self->buffer_size; } CHECK_CLOSED(self, "read of closed file") |