diff Modules/cStringIO.c @ 42493:89c81fd7038e 2.5

Revert the fix for #1548891, it broke backwards compatibility with arbitrary read buffers. Fixes #1730114. (backport from rev. 56830)
author Georg Brandl <georg@python.org>
date Wed, 08 Aug 2007 13:03:45 +0000
parents 0a6e537b8d96
children 57cd070ad304
line wrap: on
line diff
--- a/Modules/cStringIO.c	Tue Aug 07 07:13:27 2007 +0000
+++ b/Modules/cStringIO.c	Wed Aug 08 13:03:45 2007 +0000
@@ -665,8 +665,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;