[pypy-svn] r39879 - in pypy/dist/pypy: interpreter objspace objspace/std

pedronis at codespeak.net pedronis at codespeak.net
Sun Mar 4 14:16:07 CET 2007


Author: pedronis
Date: Sun Mar  4 14:16:05 2007
New Revision: 39879

Modified:
   pypy/dist/pypy/interpreter/typedef.py
   pypy/dist/pypy/objspace/descroperation.py
   pypy/dist/pypy/objspace/std/stdtypedef.py
   pypy/dist/pypy/objspace/std/stringobject.py
   pypy/dist/pypy/objspace/std/typeobject.py
   pypy/dist/pypy/objspace/std/typetype.py
Log:
use getname more consistently, helps making the taint space translatable. py.test -A tests pass.
There are still problems and open issues (also design-wise), some usages can produce
fatal internal assertion errors :(



Modified: pypy/dist/pypy/interpreter/typedef.py
==============================================================================
--- pypy/dist/pypy/interpreter/typedef.py	(original)
+++ pypy/dist/pypy/interpreter/typedef.py	Sun Mar  4 14:16:05 2007
@@ -420,8 +420,11 @@
     def typecheck(self, space, w_obj):
         if not space.is_true(space.isinstance(w_obj, self.w_cls)):
             raise OperationError(space.w_TypeError,
-                                 space.wrap("descriptor '%s' for '%s' objects doesn't apply to '%s' object" %
-                                            (self.name, self.w_cls.name, space.type(w_obj).name)))
+                              space.wrap("descriptor '%s' for '%s'"
+                              " objects doesn't apply to '%s' object" %
+                                   (self.name,
+                                    self.w_cls.name,
+                                    space.type(w_obj).getname(space, '?'))))
     
     def descr_member_get(space, member, w_obj, w_w_cls=None):
         """member.__get__(obj[, type]) -> value

Modified: pypy/dist/pypy/objspace/descroperation.py
==============================================================================
--- pypy/dist/pypy/objspace/descroperation.py	(original)
+++ pypy/dist/pypy/objspace/descroperation.py	Sun Mar  4 14:16:05 2007
@@ -8,10 +8,11 @@
 
 def raiseattrerror(space, w_obj, name, w_descr=None):
     w_type = space.type(w_obj)
+    typename = w_type.getname(space, '?')
     if w_descr is None:
-        msg = "'%s' object has no attribute '%s'" %(w_type.name, name)
+        msg = "'%s' object has no attribute '%s'" % (typename, name)
     else:
-        msg = "'%s' object attribute '%s' is read-only" %(w_type.name, name)
+        msg = "'%s' object attribute '%s' is read-only" % (typename, name)
     raise OperationError(space.w_AttributeError, space.wrap(msg))
 
 class Object:

Modified: pypy/dist/pypy/objspace/std/stdtypedef.py
==============================================================================
--- pypy/dist/pypy/objspace/std/stdtypedef.py	(original)
+++ pypy/dist/pypy/objspace/std/stdtypedef.py	Sun Mar  4 14:16:05 2007
@@ -173,7 +173,7 @@
     return prefix, list_of_typeorders
 
 def typeerrormsg(space, operatorsymbol, args_w):
-    type_names = [ space.type(w_arg).name for w_arg in args_w ]
+    type_names = [ space.type(w_arg).getname(space, '?') for w_arg in args_w ]
     if len(args_w) > 1:
         plural = 's'
     else:

Modified: pypy/dist/pypy/objspace/std/stringobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/stringobject.py	(original)
+++ pypy/dist/pypy/objspace/std/stringobject.py	Sun Mar  4 14:16:05 2007
@@ -335,7 +335,8 @@
                 raise OperationError(
                     space.w_TypeError,
                     space.wrap("sequence item %d: expected string, %s "
-                               "found" % (i, space.type(w_s).name)))
+                               "found" % (i,
+                                          space.type(w_s).getname(space, '?'))))
             l.append(space.str_w(w_s))
         return space.wrap(self.join(l))
     else:

Modified: pypy/dist/pypy/objspace/std/typeobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/typeobject.py	(original)
+++ pypy/dist/pypy/objspace/std/typeobject.py	Sun Mar  4 14:16:05 2007
@@ -347,7 +347,7 @@
         if not isinstance(w_subtype, W_TypeObject):
             raise OperationError(space.w_TypeError,
                 space.wrap("X is not a type object (%s)" % (
-                    space.type(w_subtype).name)))
+                    space.type(w_subtype).getname(space, '?'))))
         if not space.is_true(space.issubtype(w_subtype, w_self)):
             raise OperationError(space.w_TypeError,
                 space.wrap("%s.__new__(%s): %s is not a subtype of %s" % (

Modified: pypy/dist/pypy/objspace/std/typetype.py
==============================================================================
--- pypy/dist/pypy/objspace/std/typetype.py	(original)
+++ pypy/dist/pypy/objspace/std/typetype.py	Sun Mar  4 14:16:05 2007
@@ -52,7 +52,8 @@
     from pypy.objspace.std.typeobject import W_TypeObject
     if not isinstance(w_type, W_TypeObject):
         raise OperationError(space.w_TypeError,
-                             space.wrap("X is not a type object (%s)" % (space.type(w_type).name)))
+                             space.wrap("X is not a type object (%s)" %
+                                     (space.type(w_type).getname(space, '?'))))
     return w_type
 
 def _check(space, w_type, msg=None):
@@ -144,8 +145,10 @@
                                         w_type.name))
     if not space.is_true(space.isinstance(w_value, space.w_tuple)):
         raise OperationError(space.w_TypeError,
-                             space.wrap("can only assign tuple to %s.__bases__, not %s"%
-                                        (w_type.name, space.type(w_value).name)))
+                             space.wrap("can only assign tuple"
+                                        " to %s.__bases__, not %s"%
+                                     (w_type.name,
+                                      space.type(w_value).getname(space, '?'))))
     if space.int_w(space.len(w_value)) == 0:
         raise OperationError(space.w_TypeError,
                              space.wrap("can only assign non-empty tuple to %s.__bases__, not ()"%
@@ -156,8 +159,11 @@
             w_typ = space.type(w_base)
             if not space.is_w(w_typ, space.w_classobj):
                 raise OperationError(space.w_TypeError,
-                                     space.wrap("%s.__bases__ must be tuple of old- or new-style classes, not '%s'"%
-                                                (w_type.name, w_typ.name)))
+                                     space.wrap("%s.__bases__ must be tuple "
+                                                "of old- or new-style classes"
+                                                ", not '%s'"%
+                                                (w_type.name,
+                                                 w_typ.getname(space, '?'))))
         else:
             new_newstyle_bases.append(w_base)
             if space.is_true(space.issubtype(w_base, w_type)):



More information about the Pypy-commit mailing list