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

xoraxax at codespeak.net xoraxax at codespeak.net
Sun Mar 4 19:39:04 CET 2007


Author: xoraxax
Date: Sun Mar  4 19:39:02 2007
New Revision: 39915

Modified:
   pypy/branch/pypy-2.5/pypy/objspace/std/strsliceobject.py
Log:
(xorAxAx, good hint by samuele) Enable the startswith/endswith method for string slice objects and tuples.

Modified: pypy/branch/pypy-2.5/pypy/objspace/std/strsliceobject.py
==============================================================================
--- pypy/branch/pypy-2.5/pypy/objspace/std/strsliceobject.py	(original)
+++ pypy/branch/pypy-2.5/pypy/objspace/std/strsliceobject.py	Sun Mar  4 19:39:02 2007
@@ -2,6 +2,7 @@
 from pypy.objspace.std.stringobject import W_StringObject
 from pypy.objspace.std.unicodeobject import delegate_String2Unicode
 from pypy.objspace.std.sliceobject import W_SliceObject
+from pypy.objspace.std.tupleobject import W_TupleObject
 from pypy.objspace.std import slicetype
 from pypy.objspace.std.inttype import wrapint
 
@@ -139,28 +140,28 @@
                                                        w_suffix, w_start, w_end)
     return space.newbool(stringendswith(u_self, suffix, start, end))
 
-#def str_endswith__StringSlice_Tuple_ANY_ANY(space, w_self, w_suffixes, w_start, w_end):
-#    (u_self, _, start, end) = _convert_idx_params(space, w_self,
-#                                                  space.wrap(''), w_start, w_end)
-#    for w_suffix in space.unpacktuple(w_suffixes):
-#        suffix = space.str_w(w_suffix) 
-#        if stringendswith(u_self, suffix, start, end):
-#            return space.w_True
-#    return space.w_False
+def str_endswith__StringSlice_Tuple_ANY_ANY(space, w_self, w_suffixes, w_start, w_end):
+    (u_self, _, start, end) = _convert_idx_params(space, w_self,
+                                                  space.wrap(''), w_start, w_end)
+    for w_suffix in space.unpacktuple(w_suffixes):
+        suffix = space.str_w(w_suffix) 
+        if stringendswith(u_self, suffix, start, end):
+            return space.w_True
+    return space.w_False
 
 def str_startswith__StringSlice_String_ANY_ANY(space, w_self, w_prefix, w_start, w_end):
     (u_self, prefix, start, end) = _convert_idx_params(space, w_self,
                                                        w_prefix, w_start, w_end)
     return space.newbool(stringstartswith(u_self, prefix, start, end))
 
-#def str_startswith__StringSlice_Tuple_ANY_ANY(space, w_self, w_prefixes, w_start, w_end):
-#    (u_self, _, start, end) = _convert_idx_params(space, w_self, space.wrap(''),
-#                                                  w_start, w_end)
-#    for w_prefix in space.unpacktuple(w_prefixes):
-#        prefix = space.str_w(w_prefix)
-#        if stringstartswith(u_self, prefix, start, end):
-#            return space.w_True
-#    return space.w_False
+def str_startswith__StringSlice_Tuple_ANY_ANY(space, w_self, w_prefixes, w_start, w_end):
+    (u_self, _, start, end) = _convert_idx_params(space, w_self, space.wrap(''),
+                                                  w_start, w_end)
+    for w_prefix in space.unpacktuple(w_prefixes):
+        prefix = space.str_w(w_prefix)
+        if stringstartswith(u_self, prefix, start, end):
+            return space.w_True
+    return space.w_False
 
 
 def str_w__StringSlice(space, w_str):



More information about the Pypy-commit mailing list