[pypy-svn] r5628 - pypy/trunk/src/pypy/objspace/std

mwh at codespeak.net mwh at codespeak.net
Fri Jul 23 12:31:53 CEST 2004


Author: mwh
Date: Fri Jul 23 12:31:52 2004
New Revision: 5628

Modified:
   pypy/trunk/src/pypy/objspace/std/stringobject.py
Log:
the reason faked types shouldn't be specific to an instance:
turn on string to unicode delegation


Modified: pypy/trunk/src/pypy/objspace/std/stringobject.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/stringobject.py	(original)
+++ pypy/trunk/src/pypy/objspace/std/stringobject.py	Fri Jul 23 12:31:52 2004
@@ -101,6 +101,16 @@
 
 registerimplementation(W_StringObject)
 
+# string-to-unicode delegation
+import fake
+def delegate__String(space, w_str):
+    return space.wrap(unicode(space.unwrap(w_str)))
+# XXX needs to change when we stop faking unicode!
+delegate__String.result_class = fake.fake_type(unicode)
+delegate__String.priority = PRIORITY_CHANGE_TYPE
+delegate__String.can_fail = True
+
+
 def _isspace(ch):
     return ord(ch) in (9, 10, 11, 12, 13, 32)  
 
@@ -919,18 +929,6 @@
         buf[i+len(left)] = right[i]
     return space.wrap("".join(buf))
 
-def mod_str_tuple(space, w_format, w_args):
-    # XXX implement me
-    format = space.unwrap(w_format)
-    args = space.unwrap(w_args)
-    try:
-        s = format % args
-    except TypeError, e:
-        raise OperationError(space.w_TypeError, space.wrap(str(e)))
-    except ValueError, e:
-        raise OperationError(space.w_ValueError, space.wrap(str(e)))
-    return space.wrap(s)
-
 def len__String(space, w_str):
     return space.wrap(len(space.unwrap(w_str)))
 
@@ -981,8 +979,7 @@
     if isinstance(values, tuple):
         return _formatting.format(format, values, None)
     else:
-        if hasattr(values, '__getitem__') and \
-               not isinstance(values, (str, list)):
+        if hasattr(values, 'keys'):
             return _formatting.format(format, (values,), values)
         else:
             return _formatting.format(format, (values,), None)



More information about the Pypy-commit mailing list