Commit 5b2cf5e6 authored by R David Murray's avatar R David Murray

#17275: Fix class name in init errors in C bufferedio classes.

This fixes an apparent copy-and-paste error.

Original patch by Manuel Jacob.
parent f794bde1
...@@ -1004,6 +1004,12 @@ class CBufferedReaderTest(BufferedReaderTest, SizeofTest): ...@@ -1004,6 +1004,12 @@ class CBufferedReaderTest(BufferedReaderTest, SizeofTest):
support.gc_collect() support.gc_collect()
self.assertTrue(wr() is None, wr) self.assertTrue(wr() is None, wr)
def test_args_error(self):
# Issue #17275
with self.assertRaisesRegexp(TypeError, "BufferedReader"):
self.tp(io.BytesIO(), 1024, 1024, 1024)
class PyBufferedReaderTest(BufferedReaderTest): class PyBufferedReaderTest(BufferedReaderTest):
tp = pyio.BufferedReader tp = pyio.BufferedReader
...@@ -1296,6 +1302,11 @@ class CBufferedWriterTest(BufferedWriterTest, SizeofTest): ...@@ -1296,6 +1302,11 @@ class CBufferedWriterTest(BufferedWriterTest, SizeofTest):
with self.open(support.TESTFN, "rb") as f: with self.open(support.TESTFN, "rb") as f:
self.assertEqual(f.read(), b"123xxx") self.assertEqual(f.read(), b"123xxx")
def test_args_error(self):
# Issue #17275
with self.assertRaisesRegexp(TypeError, "BufferedWriter"):
self.tp(io.BytesIO(), 1024, 1024, 1024)
class PyBufferedWriterTest(BufferedWriterTest): class PyBufferedWriterTest(BufferedWriterTest):
tp = pyio.BufferedWriter tp = pyio.BufferedWriter
...@@ -1646,6 +1657,7 @@ class BufferedRandomTest(BufferedReaderTest, BufferedWriterTest): ...@@ -1646,6 +1657,7 @@ class BufferedRandomTest(BufferedReaderTest, BufferedWriterTest):
f.flush() f.flush()
self.assertEqual(raw.getvalue(), b'1b\n2def\n3\n') self.assertEqual(raw.getvalue(), b'1b\n2def\n3\n')
class CBufferedRandomTest(CBufferedReaderTest, CBufferedWriterTest, class CBufferedRandomTest(CBufferedReaderTest, CBufferedWriterTest,
BufferedRandomTest, SizeofTest): BufferedRandomTest, SizeofTest):
tp = io.BufferedRandom tp = io.BufferedRandom
...@@ -1664,6 +1676,12 @@ class CBufferedRandomTest(CBufferedReaderTest, CBufferedWriterTest, ...@@ -1664,6 +1676,12 @@ class CBufferedRandomTest(CBufferedReaderTest, CBufferedWriterTest,
CBufferedReaderTest.test_garbage_collection(self) CBufferedReaderTest.test_garbage_collection(self)
CBufferedWriterTest.test_garbage_collection(self) CBufferedWriterTest.test_garbage_collection(self)
def test_args_error(self):
# Issue #17275
with self.assertRaisesRegexp(TypeError, "BufferedRandom"):
self.tp(io.BytesIO(), 1024, 1024, 1024)
class PyBufferedRandomTest(BufferedRandomTest): class PyBufferedRandomTest(BufferedRandomTest):
tp = pyio.BufferedRandom tp = pyio.BufferedRandom
......
...@@ -466,6 +466,7 @@ Roger Irwin ...@@ -466,6 +466,7 @@ Roger Irwin
Atsuo Ishimoto Atsuo Ishimoto
Paul Jackson Paul Jackson
Ben Jackson Ben Jackson
Manuel Jacob
David Jacobs David Jacobs
Kevin Jacobs Kevin Jacobs
Kjetil Jacobsen Kjetil Jacobsen
......
...@@ -9,6 +9,9 @@ What's New in Python 2.7.4 ...@@ -9,6 +9,9 @@ What's New in Python 2.7.4
Core and Builtins Core and Builtins
----------------- -----------------
- Issue #17275: Corrected class name in init error messages of the C version of
BufferedWriter and BufferedRandom.
- Issue #7963: Fixed misleading error message that issued when object is - Issue #7963: Fixed misleading error message that issued when object is
called without arguments. called without arguments.
......
...@@ -1683,7 +1683,7 @@ bufferedwriter_init(buffered *self, PyObject *args, PyObject *kwds) ...@@ -1683,7 +1683,7 @@ bufferedwriter_init(buffered *self, PyObject *args, PyObject *kwds)
self->ok = 0; self->ok = 0;
self->detached = 0; self->detached = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|nn:BufferedReader", kwlist, if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|nn:BufferedWriter", kwlist,
&raw, &buffer_size, &max_buffer_size)) { &raw, &buffer_size, &max_buffer_size)) {
return -1; return -1;
} }
...@@ -2316,7 +2316,7 @@ bufferedrandom_init(buffered *self, PyObject *args, PyObject *kwds) ...@@ -2316,7 +2316,7 @@ bufferedrandom_init(buffered *self, PyObject *args, PyObject *kwds)
self->ok = 0; self->ok = 0;
self->detached = 0; self->detached = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|nn:BufferedReader", kwlist, if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|nn:BufferedRandom", kwlist,
&raw, &buffer_size, &max_buffer_size)) { &raw, &buffer_size, &max_buffer_size)) {
return -1; return -1;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment