[Python-checkins] r55782 - python/branches/cpy_merge/Modules/_bytes_iomodule.c python/branches/cpy_merge/Modules/_string_iomodule.c

alexandre.vassalotti python-checkins at python.org
Tue Jun 5 23:21:29 CEST 2007


Author: alexandre.vassalotti
Date: Tue Jun  5 23:21:24 2007
New Revision: 55782

Modified:
   python/branches/cpy_merge/Modules/_bytes_iomodule.c
   python/branches/cpy_merge/Modules/_string_iomodule.c
Log:
Fix a nasty bug, which caused Python to crash if the following (or
similar) example was run:
  >>> import _bytes_io
  >>> b = _bytes_io.BytesIO("hello")
  >>> b.writelines(["hello", "hello"])
  >>> b.close()



Modified: python/branches/cpy_merge/Modules/_bytes_iomodule.c
==============================================================================
--- python/branches/cpy_merge/Modules/_bytes_iomodule.c	(original)
+++ python/branches/cpy_merge/Modules/_bytes_iomodule.c	Tue Jun  5 23:21:24 2007
@@ -424,6 +424,7 @@
        anything to the object. */
     self->pos = 0;
     self->string_size = 0;
+    self->buf_size = size;
 
     if (n > 0) {
         if (write_bytes(self, buf, n) == -1)
@@ -434,7 +435,6 @@
         Py_DECREF(self);
         return PyErr_NoMemory();
     }
-    self->buf_size = size;
 
     return (PyObject *)self;
 }

Modified: python/branches/cpy_merge/Modules/_string_iomodule.c
==============================================================================
--- python/branches/cpy_merge/Modules/_string_iomodule.c	(original)
+++ python/branches/cpy_merge/Modules/_string_iomodule.c	Tue Jun  5 23:21:24 2007
@@ -434,6 +434,7 @@
        anything to the object. */
     self->pos = 0;
     self->string_size = 0;
+    self->buf_size = size;
 
     if (n > 0) {
         if (write_str(self, buf, n) == -1)
@@ -444,7 +445,6 @@
         Py_DECREF(self);
         return PyErr_NoMemory();
     }
-    self->buf_size = size;
 
     return (PyObject *)self;
 }


More information about the Python-checkins mailing list