[pypy-svn] r39916 - pypy/branch/pypy-2.5/pypy/objspace/std

gbrandl at codespeak.net gbrandl at codespeak.net
Sun Mar 4 19:39:12 CET 2007


Author: gbrandl
Date: Sun Mar  4 19:39:09 2007
New Revision: 39916

Modified:
   pypy/branch/pypy-2.5/pypy/objspace/std/unicodeobject.py
Log:
str.startswith and endswith with tuple argument for unicode too.



Modified: pypy/branch/pypy-2.5/pypy/objspace/std/unicodeobject.py
==============================================================================
--- pypy/branch/pypy-2.5/pypy/objspace/std/unicodeobject.py	(original)
+++ pypy/branch/pypy-2.5/pypy/objspace/std/unicodeobject.py	Sun Mar  4 19:39:09 2007
@@ -3,6 +3,7 @@
 from pypy.objspace.std.stringobject import W_StringObject
 from pypy.objspace.std.noneobject import W_NoneObject
 from pypy.objspace.std.sliceobject import W_SliceObject
+from pypy.objspace.std.tupleobject import W_TupleObject
 from pypy.rlib.rarithmetic import intmask, ovfcheck
 from pypy.module.unicodedata import unicodedb_3_2_0 as unicodedb
 
@@ -881,7 +882,17 @@
     else:
         return (unistr[:pos], unisub, unistr[pos+len(unisub):])
 
-#def unicode_startswith_
+def unicode_startswith__Unicode_Tuple_ANY_ANY(unistr, prefixes, start, end):
+    for prefix in prefixes:
+        if unistr.startswith(prefix):
+            return True
+    return False
+
+def unicode_endswith__Unicode_Tuple_ANY_ANY(unistr, suffixes, start, end):
+    for suffix in suffixes:
+        if unistr.endswith(suffix):
+            return True
+    return False
 
 ''')
 
@@ -891,6 +902,8 @@
 unicode_encode__Unicode_ANY_ANY = app.interphook('unicode_encode__Unicode_ANY_ANY')
 unicode_partition__Unicode_Unicode = app.interphook('unicode_partition__Unicode_Unicode')
 unicode_rpartition__Unicode_Unicode = app.interphook('unicode_rpartition__Unicode_Unicode')
+unicode_startswith__Unicode_Tuple_ANY_ANY = app.interphook('unicode_startswith__Unicode_Tuple_ANY_ANY')
+unicode_endswith__Unicode_Tuple_ANY_ANY = app.interphook('unicode_endswith__Unicode_Tuple_ANY_ANY')
 
 # Move this into the _codecs module as 'unicodeescape_string (Remember to cater for quotes)'
 def repr__Unicode(space, w_unicode):



More information about the Pypy-commit mailing list