[pypy-commit] pypy utf8-unicode2: Explicitly raise the IndexError for str objects

waedt noreply at buildbot.pypy.org
Sun Aug 10 09:14:57 CEST 2014


Author: Tyler Wade <wayedt at gmail.com>
Branch: utf8-unicode2
Changeset: r72739:b895651fbbdc
Date: 2014-08-09 23:50 -0500
http://bitbucket.org/pypy/pypy/changeset/b895651fbbdc/

Log:	Explicitly raise the IndexError for str objects

diff --git a/pypy/interpreter/utf8.py b/pypy/interpreter/utf8.py
--- a/pypy/interpreter/utf8.py
+++ b/pypy/interpreter/utf8.py
@@ -50,15 +50,16 @@
     return res
 
 def utf8ord(ustr, start=0):
-    if start >= len(ustr):
-        raise IndexError()
-
     start = ustr.index_of_char(start)
     return utf8ord_bytes(ustr.bytes, start)
 
 @specialize.argtype(0)
 def ORD(s, pos):
     assert s is not None
+
+    if pos >= len(s):
+        raise IndexError()
+
     if isinstance(s, Utf8Str):
         return utf8ord(s, pos)
     else:
@@ -493,7 +494,6 @@
         res.reverse()
         return res
 
-    #@specialize.argtype(1)
     def join(self, other):
         if len(other) == 0:
             return Utf8Str('')


More information about the pypy-commit mailing list