[Python-3000-checkins] r56839 - in python/branches/py3k-struni: Lib/test/test_bytes.py Objects/bytesobject.c
guido.van.rossum
python-3000-checkins at python.org
Wed Aug 8 23:55:34 CEST 2007
Author: guido.van.rossum
Date: Wed Aug 8 23:55:33 2007
New Revision: 56839
Modified:
python/branches/py3k-struni/Lib/test/test_bytes.py
python/branches/py3k-struni/Objects/bytesobject.c
Log:
Fix core dump in an endcase of b.strip() that I missed.
Modified: python/branches/py3k-struni/Lib/test/test_bytes.py
==============================================================================
--- python/branches/py3k-struni/Lib/test/test_bytes.py (original)
+++ python/branches/py3k-struni/Lib/test/test_bytes.py Wed Aug 8 23:55:33 2007
@@ -653,6 +653,7 @@
self.assertEqual(b.strip(b'pi'), b'mississ')
self.assertEqual(b.strip(b'im'), b'ssissipp')
self.assertEqual(b.strip(b'pim'), b'ssiss')
+ self.assertEqual(b.strip(b), b'')
def test_lstrip(self):
b = b'mississippi'
Modified: python/branches/py3k-struni/Objects/bytesobject.c
==============================================================================
--- python/branches/py3k-struni/Objects/bytesobject.c (original)
+++ python/branches/py3k-struni/Objects/bytesobject.c Wed Aug 8 23:55:33 2007
@@ -2502,7 +2502,10 @@
argptr = ((PyBytesObject *)arg)->ob_bytes;
argsize = Py_Size(arg);
left = lstrip_helper(myptr, mysize, argptr, argsize);
- right = rstrip_helper(myptr, mysize, argptr, argsize);
+ if (left == mysize)
+ right = left;
+ else
+ right = rstrip_helper(myptr, mysize, argptr, argsize);
return PyBytes_FromStringAndSize(self->ob_bytes + left, right - left);
}
More information about the Python-3000-checkins
mailing list