Skip to content

Commit 9f10f56

Browse files
committed
Merge #17275: Fix class name in init errors in C bufferedio classes.
This fixes an apparent copy-and-paste error. Patch by Manuel Jacob.
2 parents e766c74 + 67bfe80 commit 9f10f56

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

Lib/test/test_io.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,6 +1072,12 @@ def test_garbage_collection(self):
10721072
support.gc_collect()
10731073
self.assertTrue(wr() is None, wr)
10741074

1075+
def test_args_error(self):
1076+
# Issue #17275
1077+
with self.assertRaisesRegex(TypeError, "BufferedReader"):
1078+
self.tp(io.BytesIO(), 1024, 1024, 1024)
1079+
1080+
10751081
class PyBufferedReaderTest(BufferedReaderTest):
10761082
tp = pyio.BufferedReader
10771083

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

1372+
def test_args_error(self):
1373+
# Issue #17275
1374+
with self.assertRaisesRegex(TypeError, "BufferedWriter"):
1375+
self.tp(io.BytesIO(), 1024, 1024, 1024)
1376+
13661377

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

1729+
17181730
class CBufferedRandomTest(BufferedRandomTest, SizeofTest):
17191731
tp = io.BufferedRandom
17201732

@@ -1732,6 +1744,12 @@ def test_garbage_collection(self):
17321744
CBufferedReaderTest.test_garbage_collection(self)
17331745
CBufferedWriterTest.test_garbage_collection(self)
17341746

1747+
def test_args_error(self):
1748+
# Issue #17275
1749+
with self.assertRaisesRegex(TypeError, "BufferedRandom"):
1750+
self.tp(io.BytesIO(), 1024, 1024, 1024)
1751+
1752+
17351753
class PyBufferedRandomTest(BufferedRandomTest):
17361754
tp = pyio.BufferedRandom
17371755

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,7 @@ Atsuo Ishimoto
555555
Adam Jackson
556556
Ben Jackson
557557
Paul Jackson
558+
Manuel Jacob
558559
David Jacobs
559560
Kevin Jacobs
560561
Kjetil Jacobsen

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ What's New in Python 3.3.1?
1212
Core and Builtins
1313
-----------------
1414

15+
- Issue #17275: Corrected class name in init error messages of the C version of
16+
BufferedWriter and BufferedRandom.
17+
1518
- Issue #7963: Fixed misleading error message that issued when object is
1619
called without arguments.
1720

Modules/_io/bufferedio.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,7 +1817,7 @@ bufferedwriter_init(buffered *self, PyObject *args, PyObject *kwds)
18171817
self->ok = 0;
18181818
self->detached = 0;
18191819

1820-
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|n:BufferedReader", kwlist,
1820+
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|n:BufferedWriter", kwlist,
18211821
&raw, &buffer_size)) {
18221822
return -1;
18231823
}
@@ -2446,7 +2446,7 @@ bufferedrandom_init(buffered *self, PyObject *args, PyObject *kwds)
24462446
self->ok = 0;
24472447
self->detached = 0;
24482448

2449-
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|n:BufferedReader", kwlist,
2449+
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|n:BufferedRandom", kwlist,
24502450
&raw, &buffer_size)) {
24512451
return -1;
24522452
}

0 commit comments

Comments
 (0)