diff Modules/cStringIO.c @ 42492:86fd39c2c676 legacy-trunk

Revert the fix for #1548891, it broke backwards compatibility with arbitrary read buffers. Fixes #1730114.
author Georg Brandl <georg@python.org>
date Wed, 08 Aug 2007 13:03:41 +0000
parents 6620a510e9a9
children 3f6be12b9534
line wrap: on
line diff
--- a/Modules/cStringIO.c	Tue Aug 07 07:13:24 2007 +0000
+++ b/Modules/cStringIO.c	Wed Aug 08 13:03:41 2007 +0000
@@ -673,8 +673,11 @@
   char *buf;
   Py_ssize_t size;
 
-  if (PyObject_AsCharBuffer(s, (const char **)&buf, &size) != 0)
-      return NULL;
+  if (PyObject_AsReadBuffer(s, (const char **)&buf, &size)) {
+    PyErr_Format(PyExc_TypeError, "expected read buffer, %.200s found",
+                 s->ob_type->tp_name);
+    return NULL;
+  }
 
   self = PyObject_New(Iobject, &Itype);
   if (!self) return NULL;