Commits

Manuel Jacob committed 85197e0

Fix annotation.

  • Participants
  • Parent commits 1dfbad2
  • Branches refactor-str-types

Comments (0)

Files changed (1)

rpython/rlib/rstring.py

 
 from rpython.annotator.model import (SomeObject, SomeString, s_None, SomeChar,
     SomeInteger, SomeUnicodeCodePoint, SomeUnicodeString, SomePtr, SomePBC)
+from rpython.rlib import jit
 from rpython.rlib.objectmodel import newlist_hint, specialize
 from rpython.rlib.rarithmetic import ovfcheck
+from rpython.rlib.unicodedata import unicodedb_5_2_0 as unicodedb
 from rpython.rtyper.extregistry import ExtRegistryEntry
 from rpython.tool.pairtype import pairtype
-from rpython.rlib import jit
 
 
 # -------------- public API for string functions -----------------------
 
+def _isspace(char):
+    if isinstance(char, str):
+        return char.isspace()
+    else:
+        assert isinstance(char, unicode)
+        return unicodedb.isspace(ord(char))
+
+
 @specialize.argtype(0)
 def split(value, by=None, maxsplit=-1):
     if by is None:
         while True:
             # find the beginning of the next word
             while i < length:
-                if not value[i].isspace():
+                if not _isspace(value[i]):
                     break   # found
                 i += 1
             else:
                 j = length   # take all the rest of the string
             else:
                 j = i + 1
-                while j < length and not value[j].isspace():
+                while j < length and not _isspace(value[j]):
                     j += 1
                 maxsplit -= 1   # NB. if it's already < 0, it stays < 0
 
         while True:
             # starting from the end, find the end of the next word
             while i >= 0:
-                if not value[i].isspace():
+                if not _isspace(value[i]):
                     break   # found
                 i -= 1
             else:
                 j = -1   # take all the rest of the string
             else:
                 j = i - 1
-                while j >= 0 and not value[j].isspace():
+                while j >= 0 and not _isspace(value[j]):
                     j -= 1
                 maxsplit -= 1   # NB. if it's already < 0, it stays < 0