Author: Matti Picus <[email protected]>
Branch: unicode-utf8
Changeset: r95566:345fe0eeb01c
Date: 2019-01-02 10:58 +0200
http://bitbucket.org/pypy/pypy/changeset/345fe0eeb01c/

Log:    test, fix for u'aaa'.count('', 10) == 0, u'aaa'.count('', 3) == 1

diff --git a/pypy/objspace/std/test/test_unicodeobject.py 
b/pypy/objspace/std/test/test_unicodeobject.py
--- a/pypy/objspace/std/test/test_unicodeobject.py
+++ b/pypy/objspace/std/test/test_unicodeobject.py
@@ -898,7 +898,9 @@
         raises(UnicodeDecodeError, '\x80'.rindex, u'')
         assert u"\u1234\u5678".find(u'\u5678') == 1
 
-    def test_count(self):
+    def test_count_unicode(self):
+        assert u'aaa'.count('', 10) == 0
+        assert u'aaa'.count('', 3) == 1
         assert u"".count(u"x") ==0
         assert u"".count(u"") ==1
         assert u"Python".count(u"") ==7
diff --git a/pypy/objspace/std/unicodeobject.py 
b/pypy/objspace/std/unicodeobject.py
--- a/pypy/objspace/std/unicodeobject.py
+++ b/pypy/objspace/std/unicodeobject.py
@@ -921,7 +921,7 @@
         # 'end_index' are measured in bytes.
         start, end = unwrap_start_stop(space, self._length, w_start, w_end)
         start_index = 0
-        end_index = len(self._utf8)
+        end_index = len(self._utf8) + 1
         if start > 0:
             if start > self._length:
                 start_index = end_index
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to