[pypy-commit] pypy numpy-minilang: more bugs in strip

fijal noreply at buildbot.pypy.org
Fri Oct 28 12:14:33 CEST 2011


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: numpy-minilang
Changeset: r48556:75b8ab99578c
Date: 2011-10-28 12:11 +0200
http://bitbucket.org/pypy/pypy/changeset/75b8ab99578c/

Log:	more bugs in strip

diff --git a/pypy/rpython/lltypesystem/rstr.py b/pypy/rpython/lltypesystem/rstr.py
--- a/pypy/rpython/lltypesystem/rstr.py
+++ b/pypy/rpython/lltypesystem/rstr.py
@@ -365,9 +365,9 @@
             while lpos < rpos and s.chars[lpos] == ch:
                 lpos += 1
         if right:
-            while lpos < rpos and s.chars[rpos] == ch:
+            while lpos < rpos + 1 and s.chars[rpos] == ch:
                 rpos -= 1
-        if rpos <= lpos:
+        if rpos < lpos:
             return s.empty()
         r_len = rpos - lpos + 1
         result = s.malloc(r_len)
diff --git a/pypy/rpython/test/test_rstr.py b/pypy/rpython/test/test_rstr.py
--- a/pypy/rpython/test/test_rstr.py
+++ b/pypy/rpython/test/test_rstr.py
@@ -374,6 +374,8 @@
             return const('!ab!').rstrip(const('!'))
         def empty():
             return const('    ').strip(' ')
+        def left2():
+            return const('a  ').strip(' ')
         res = self.interpret(both, [])
         assert self.ll_to_string(res) == const('ab')
         res = self.interpret(left, [])
@@ -382,6 +384,8 @@
         assert self.ll_to_string(res) == const('!ab')
         res = self.interpret(empty, [])
         assert self.ll_to_string(res) == const('')
+        res = self.interpret(left2, [])
+        assert self.ll_to_string(res) == const('a')
 
     def test_upper(self):
         const = self.const


More information about the pypy-commit mailing list