[Python-checkins] r57217 - python/branches/alex-py3k/Modules/_bytesiomodule.c python/branches/alex-py3k/Modules/_stringiomodule.c

alexandre.vassalotti python-checkins at python.org
Mon Aug 20 18:13:13 CEST 2007


Author: alexandre.vassalotti
Date: Mon Aug 20 18:13:12 2007
New Revision: 57217

Modified:
   python/branches/alex-py3k/Modules/_bytesiomodule.c
   python/branches/alex-py3k/Modules/_stringiomodule.c
Log:
Do not call resize_buffer() when seeking within the string size.


Modified: python/branches/alex-py3k/Modules/_bytesiomodule.c
==============================================================================
--- python/branches/alex-py3k/Modules/_bytesiomodule.c	(original)
+++ python/branches/alex-py3k/Modules/_bytesiomodule.c	Mon Aug 20 18:13:12 2007
@@ -367,8 +367,10 @@
     if (newpos < 0)
         newpos = 0;
 
-    if (resize_buffer(self, newpos) < 0)
-        return NULL;  /* out of memory */
+    if (newpos >= self->string_size) {
+        if (resize_buffer(self, newpos + 1) < 0)
+            return NULL;  /* out of memory */
+    }
 
     prevpos = self->pos;
     self->pos = newpos;

Modified: python/branches/alex-py3k/Modules/_stringiomodule.c
==============================================================================
--- python/branches/alex-py3k/Modules/_stringiomodule.c	(original)
+++ python/branches/alex-py3k/Modules/_stringiomodule.c	Mon Aug 20 18:13:12 2007
@@ -332,8 +332,10 @@
     if (newpos < 0)
         newpos = 0;
 
-    if (resize_buffer(self, newpos) < 0)
-        return NULL;  /* out of memory */
+    if (newpos >= self->string_size) {
+        if (resize_buffer(self, newpos + 1) < 0)
+            return NULL;  /* out of memory */
+    }
 
     prevpos = self->pos;
     self->pos = newpos;


More information about the Python-checkins mailing list