Author: fijal
Branch: unicode-utf8
Changeset: r92848:e1df137224a1
Date: 2017-10-26 11:44 +0200
http://bitbucket.org/pypy/pypy/changeset/e1df137224a1/

Log:    write down _sliced version for unicode

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
@@ -756,7 +756,16 @@
         if start == stop:
             return self._empty()
         else:
-            return self._sliced(space, selfvalue, start, stop, self)
+            return self._unicode_sliced(space, start, stop)
+
+    def _unicode_sliced(self, space, start, stop):
+        # XXX maybe some heuristic, like first slice does not create
+        #     full index, but second does?
+        assert start >= 0
+        assert stop >= 0
+        byte_start = self._index_to_byte(start)
+        byte_stop = self._index_to_byte(stop)
+        return W_UnicodeObject(self._utf8[byte_start:byte_stop], stop - start)
 
     def descr_capitalize(self, space):
         value = self._utf8
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to