diff options
author | Guido van Rossum <guido@python.org> | 2007-08-08 21:55:33 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-08-08 21:55:33 (GMT) |
commit | eb29e9ab2b037db198591a9cacb5993385c7f83d (patch) | |
tree | 0748abafc847fcd708af120f2834e2737aceabe9 | |
parent | 2fb5ac745bf2edd03261ca8144eb73a1f6e54af3 (diff) | |
download | cpython-eb29e9ab2b037db198591a9cacb5993385c7f83d.zip cpython-eb29e9ab2b037db198591a9cacb5993385c7f83d.tar.gz cpython-eb29e9ab2b037db198591a9cacb5993385c7f83d.tar.bz2 |
Fix core dump in an endcase of b.strip() that I missed.
-rw-r--r-- | Lib/test/test_bytes.py | 1 | ||||
-rw-r--r-- | Objects/bytesobject.c | 5 |
2 files changed, 5 insertions, 1 deletions
diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py index 094c56c..654cb86 100644 --- a/Lib/test/test_bytes.py +++ b/Lib/test/test_bytes.py @@ -653,6 +653,7 @@ class BytesTest(unittest.TestCase): 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' diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c index 47ee8a4..b409a28 100644 --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -2502,7 +2502,10 @@ bytes_strip(PyBytesObject *self, PyObject *arg) 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); } |