[pypy-svn] r8583 - pypy/dist/pypy/objspace/std

ludal at codespeak.net ludal at codespeak.net
Tue Jan 25 18:15:26 CET 2005


Author: ludal
Date: Tue Jan 25 18:15:26 2005
New Revision: 8583

Modified:
   pypy/dist/pypy/objspace/std/unicodeobject.py
Log:
* adds ne,le,ge,gt operators to faked unicode objects
* adds str.strip(unicode) here to avoid references to unicode objects in stringobject.py


Modified: pypy/dist/pypy/objspace/std/unicodeobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/unicodeobject.py	(original)
+++ pypy/dist/pypy/objspace/std/unicodeobject.py	Tue Jan 25 18:15:26 2005
@@ -17,12 +17,37 @@
     except:
         wrap_exception(space)
 
+def ne__Unicode_ANY(space, w_uni, w_other):
+    try:
+        return space.newbool(space.unwrap(w_uni) != space.unwrap(w_other))
+    except:
+        wrap_exception(space)
+
+
 def lt__Unicode_ANY(space, w_uni, w_other):
     try:
         return space.newbool(space.unwrap(w_uni) < space.unwrap(w_other))
     except:
         wrap_exception(space)
 
+def gt__Unicode_ANY(space, w_uni, w_other):
+    try:
+        return space.newbool(space.unwrap(w_uni) > space.unwrap(w_other))
+    except:
+        wrap_exception(space)
+
+def le__Unicode_ANY(space, w_uni, w_other):
+    try:
+        return space.newbool(space.unwrap(w_uni) <= space.unwrap(w_other))
+    except:
+        wrap_exception(space)
+
+def ge__Unicode_ANY(space, w_uni, w_other):
+    try:
+        return space.newbool(space.unwrap(w_uni) >= space.unwrap(w_other))
+    except:
+        wrap_exception(space)
+
 def ord__Unicode(space, w_uni):
     try:
         return space.wrap(ord(w_uni.val))
@@ -38,4 +63,18 @@
 def contains__Unicode_Unicode(space, w_left, w_right):
     return space.wrap(space.unwrap(w_right) in space.unwrap(w_left))
 
-register_all(vars())
+# str.strip(unicode) needs to convert self to unicode and call unicode.strip
+def str_strip__String_Unicode(space, w_self, w_chars ):
+    self = w_self._value
+    return space.wrap( unicode(self).strip( space.unwrap(w_chars) ) )
+def str_lstrip__String_Unicode(space, w_self, w_chars ):
+    self = w_self._value
+    return space.wrap( unicode(self).lstrip( space.unwrap(w_chars) ) )
+def str_rstrip__String_Unicode(space, w_self, w_chars ):
+    self = w_self._value
+    return space.wrap( unicode(self).rstrip( space.unwrap(w_chars) ) )
+# we use the following magic to register strip_string_unicode as a String multimethod
+import stringtype
+
+
+register_all(vars(), stringtype)



More information about the Pypy-commit mailing list