]> granicus.if.org Git - python/commitdiff
#17275: Fix class name in init errors in C bufferedio classes.
authorR David Murray <rdmurray@bitdance.com>
Sun, 24 Feb 2013 02:51:05 +0000 (21:51 -0500)
committerR David Murray <rdmurray@bitdance.com>
Sun, 24 Feb 2013 02:51:05 +0000 (21:51 -0500)
This fixes an apparent copy-and-paste error.

Patch by Manuel Jacob.

Lib/test/test_io.py
Misc/ACKS
Misc/NEWS
Modules/_io/bufferedio.c

index a7e596a5865e5d6018679b10df86fb31c1c2a580..8ef314e55d20ea3073197af75d4616a19f349fb0 100644 (file)
@@ -1039,6 +1039,12 @@ class CBufferedReaderTest(BufferedReaderTest, SizeofTest):
         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
 
@@ -1321,6 +1327,11 @@ class CBufferedWriterTest(BufferedWriterTest, SizeofTest):
         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
@@ -1674,6 +1685,7 @@ class BufferedRandomTest(BufferedReaderTest, BufferedWriterTest):
     # You can't construct a BufferedRandom over a non-seekable stream.
     test_unseekable = None
 
+
 class CBufferedRandomTest(BufferedRandomTest, SizeofTest):
     tp = io.BufferedRandom
 
@@ -1691,6 +1703,12 @@ class CBufferedRandomTest(BufferedRandomTest, SizeofTest):
         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
 
index 39195ef665c096d211afd2e677df40e877fc1866..8fbf9d083dc4cd193e02e24957a2088a5d9d5051 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -505,6 +505,7 @@ Atsuo Ishimoto
 Adam Jackson
 Ben Jackson
 Paul Jackson
+Manuel Jacob
 David Jacobs
 Kevin Jacobs
 Kjetil Jacobsen
index c4a89f0713ac36f22c8eee5821af517c22294037..eb30662d8d3824de87897b9353ee4021af04b433 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@ What's New in Python 3.2.4
 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.
 
index bb77acc07051cb687a765d5d1b87f8fa3a8d3c80..a8278d466ce1d25bc8c4a7458bf1cbe5a25d5824 100644 (file)
@@ -1702,7 +1702,7 @@ bufferedwriter_init(buffered *self, PyObject *args, PyObject *kwds)
     self->ok = 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)) {
         return -1;
     }
@@ -2339,7 +2339,7 @@ bufferedrandom_init(buffered *self, PyObject *args, PyObject *kwds)
     self->ok = 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)) {
         return -1;
     }