Skip to content

Commit

Permalink
Merge #17275: Fix class name in init errors in C bufferedio classes.
Browse files Browse the repository at this point in the history
This fixes an apparent copy-and-paste error.

Patch by Manuel Jacob.
  • Loading branch information
bitdancer committed Feb 24, 2013
2 parents e766c74 + 67bfe80 commit 9f10f56
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
18 changes: 18 additions & 0 deletions Lib/test/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -1072,6 +1072,12 @@ def test_garbage_collection(self):
support.gc_collect()
self.assertTrue(wr() is None, wr)

def test_args_error(self):
# Issue #17275
with self.assertRaisesRegex(TypeError, "BufferedReader"):
self.tp(io.BytesIO(), 1024, 1024, 1024)


class PyBufferedReaderTest(BufferedReaderTest):
tp = pyio.BufferedReader

Expand Down Expand Up @@ -1363,6 +1369,11 @@ def test_garbage_collection(self):
with self.open(support.TESTFN, "rb") as f:
self.assertEqual(f.read(), b"123xxx")

def test_args_error(self):
# Issue #17275
with self.assertRaisesRegex(TypeError, "BufferedWriter"):
self.tp(io.BytesIO(), 1024, 1024, 1024)


class PyBufferedWriterTest(BufferedWriterTest):
tp = pyio.BufferedWriter
Expand Down Expand Up @@ -1715,6 +1726,7 @@ def test_interleaved_readline_write(self):
# You can't construct a BufferedRandom over a non-seekable stream.
test_unseekable = None


class CBufferedRandomTest(BufferedRandomTest, SizeofTest):
tp = io.BufferedRandom

Expand All @@ -1732,6 +1744,12 @@ def test_garbage_collection(self):
CBufferedReaderTest.test_garbage_collection(self)
CBufferedWriterTest.test_garbage_collection(self)

def test_args_error(self):
# Issue #17275
with self.assertRaisesRegex(TypeError, "BufferedRandom"):
self.tp(io.BytesIO(), 1024, 1024, 1024)


class PyBufferedRandomTest(BufferedRandomTest):
tp = pyio.BufferedRandom

Expand Down
1 change: 1 addition & 0 deletions Misc/ACKS
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ Atsuo Ishimoto
Adam Jackson
Ben Jackson
Paul Jackson
Manuel Jacob
David Jacobs
Kevin Jacobs
Kjetil Jacobsen
Expand Down
3 changes: 3 additions & 0 deletions Misc/NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ What's New in Python 3.3.1?
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
called without arguments.

Expand Down
4 changes: 2 additions & 2 deletions Modules/_io/bufferedio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1817,7 +1817,7 @@ bufferedwriter_init(buffered *self, PyObject *args, PyObject *kwds)
self->ok = 0;
self->detached = 0;

if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|n:BufferedReader", kwlist,
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|n:BufferedWriter", kwlist,
&raw, &buffer_size)) {
return -1;
}
Expand Down Expand Up @@ -2446,7 +2446,7 @@ bufferedrandom_init(buffered *self, PyObject *args, PyObject *kwds)
self->ok = 0;
self->detached = 0;

if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|n:BufferedReader", kwlist,
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|n:BufferedRandom", kwlist,
&raw, &buffer_size)) {
return -1;
}
Expand Down

0 comments on commit 9f10f56

Please sign in to comment.