Author: Maciej Fijalkowski <[email protected]>
Branch: kill-unary-multimethods
Changeset: r47302:589623001029
Date: 2011-09-16 12:18 +0200
http://bitbucket.org/pypy/pypy/changeset/589623001029/

Log:    remove unicode_w

diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -192,6 +192,11 @@
         w_msg = typed_unwrap_error_msg(space, "string", self)
         raise OperationError(space.w_TypeError, w_msg)
 
+    def unicode_w(self, space):
+        raise OperationError(space.w_TypeError,
+                             typed_unwrap_error_msg(space, "unicode", self))
+
+
 
 class Wrappable(W_Root):
     """A subclass of Wrappable is an internal, interpreter-level class
@@ -1223,6 +1228,9 @@
                                  self.wrap('argument must be a string'))
         return self.str_w(w_obj)
 
+    def unicode_w(self, w_obj):
+        return w_obj.unicode_w(self)
+
     def realunicode_w(self, w_obj):
         # Like unicode_w, but only works if w_obj is really of type
         # 'unicode'.
diff --git a/pypy/objspace/std/default.py b/pypy/objspace/std/default.py
--- a/pypy/objspace/std/default.py
+++ b/pypy/objspace/std/default.py
@@ -29,10 +29,6 @@
     raise OperationError(space.w_TypeError,
                          typed_unwrap_error_msg(space, "integer", w_obj))
 
-def unicode_w__ANY(space,w_obj):
-    raise OperationError(space.w_TypeError,
-                         typed_unwrap_error_msg(space, "unicode", w_obj))
-
 def bigint_w__ANY(space,w_obj):
     raise OperationError(space.w_TypeError,
                          typed_unwrap_error_msg(space, "integer", w_obj))
diff --git a/pypy/objspace/std/model.py b/pypy/objspace/std/model.py
--- a/pypy/objspace/std/model.py
+++ b/pypy/objspace/std/model.py
@@ -454,7 +454,6 @@
     int_w   = StdObjSpaceMultiMethod('int_w', 1, [])     # returns an 
unwrapped int
     float_w = StdObjSpaceMultiMethod('float_w', 1, [])   # returns an 
unwrapped float
     uint_w  = StdObjSpaceMultiMethod('uint_w', 1, [])    # returns an 
unwrapped unsigned int (r_uint)
-    unicode_w = StdObjSpaceMultiMethod('unicode_w', 1, [])    # returns an 
unwrapped list of unicode characters
     bigint_w = StdObjSpaceMultiMethod('bigint_w', 1, []) # returns an 
unwrapped rbigint
     # NOTE: when adding more sometype_w() methods, you need to write a
     # stub in default.py to raise a space.w_TypeError
diff --git a/pypy/objspace/std/ropeunicodeobject.py 
b/pypy/objspace/std/ropeunicodeobject.py
--- a/pypy/objspace/std/ropeunicodeobject.py
+++ b/pypy/objspace/std/ropeunicodeobject.py
@@ -99,6 +99,9 @@
             return w_self
         return W_RopeUnicodeObject(w_self._node)
 
+    def unicode_w(self, space):
+        return self._node.flatten_unicode()
+
 W_RopeUnicodeObject.EMPTY = W_RopeUnicodeObject(rope.LiteralStringNode.EMPTY)
 
 registerimplementation(W_RopeUnicodeObject)
@@ -160,9 +163,6 @@
     assert isinstance(w_uni, W_RopeUnicodeObject) # help the annotator!
     return w_uni
 
-def unicode_w__RopeUnicode(space, w_uni):
-    return w_uni._node.flatten_unicode()
-
 def str__RopeUnicode(space, w_uni):
     return space.call_method(w_uni, 'encode')
 
diff --git a/pypy/objspace/std/stringobject.py 
b/pypy/objspace/std/stringobject.py
--- a/pypy/objspace/std/stringobject.py
+++ b/pypy/objspace/std/stringobject.py
@@ -36,17 +36,17 @@
     def str_w(w_self, space):
         return w_self._value
 
+    def unicode_w(w_self, space):
+        # XXX should this use the default encoding?
+        from pypy.objspace.std.unicodetype import plain_str2unicode
+        return plain_str2unicode(space, w_self._value)
+
 registerimplementation(W_StringObject)
 
 W_StringObject.EMPTY = W_StringObject('')
 W_StringObject.PREBUILT = [W_StringObject(chr(i)) for i in range(256)]
 del i
 
-def unicode_w__String(space, w_self):
-    # XXX should this use the default encoding?
-    from pypy.objspace.std.unicodetype import plain_str2unicode
-    return plain_str2unicode(space, w_self._value)
-
 def _is_generic(space, w_self, fun):
     v = w_self._value
     if len(v) == 0:
diff --git a/pypy/objspace/std/unicodeobject.py 
b/pypy/objspace/std/unicodeobject.py
--- a/pypy/objspace/std/unicodeobject.py
+++ b/pypy/objspace/std/unicodeobject.py
@@ -40,8 +40,11 @@
             return w_self
         return W_UnicodeObject(w_self._value)
 
-    def str_w(w_self, space):
-        return space.str_w(space.str(w_self))
+    def str_w(self, space):
+        return space.str_w(space.str(self))
+
+    def unicode_w(self, space):
+        return self._value
 
 W_UnicodeObject.EMPTY = W_UnicodeObject(u'')
 
@@ -102,9 +105,6 @@
         return space.not_(result)
     return result
 
-def unicode_w__Unicode(space, w_uni):
-    return w_uni._value
-
 def str__Unicode(space, w_uni):
     from pypy.objspace.std.unicodetype import encode_object
     return encode_object(space, w_uni, None, None)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to