[pypy-svn] pypy default: Make the "default" argument of getname() optional.

arigo commits-noreply at bitbucket.org
Wed Dec 29 10:35:39 CET 2010


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r40262:815cd3441bed
Date: 2010-12-29 10:34 +0100
http://bitbucket.org/pypy/pypy/changeset/815cd3441bed/

Log:	Make the "default" argument of getname() optional. Remove usage of
	the '?' at least in the interpreter/ and the objspace/ directories.

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
@@ -49,7 +49,7 @@
     if not isinstance(w_unistr, W_UnicodeObject):
         raise operationerrfmt(space.w_TypeError,
                               "expected unicode, got '%s'",
-                              space.type(w_unistr).getname(space, '?'))
+                              space.type(w_unistr).getname(space))
     unistr = w_unistr._value
     result = ['\0'] * len(unistr)
     digits = [ '0', '1', '2', '3', '4',

diff --git a/pypy/interpreter/function.py b/pypy/interpreter/function.py
--- a/pypy/interpreter/function.py
+++ b/pypy/interpreter/function.py
@@ -444,7 +444,7 @@
             pre = "bound"
         else:
             pre = "unbound"
-        return "%s method %s" % (pre, self.w_function.getname(self.space, '?'))
+        return "%s method %s" % (pre, self.w_function.getname(self.space))
 
     def call_args(self, args):
         space = self.space
@@ -493,13 +493,13 @@
 
     def descr_method_repr(self):
         space = self.space
-        name = self.w_function.getname(self.space, '?')
+        name = self.w_function.getname(self.space)
         # XXX do we handle all cases sanely here?
         if space.is_w(self.w_class, space.w_None):
             w_class = space.type(self.w_instance)
         else:
             w_class = self.w_class
-        typename = w_class.getname(self.space, '?')
+        typename = w_class.getname(self.space)
         if self.w_instance is None:
             s = "<unbound method %s.%s>" % (typename, name)
             return space.wrap(s)
@@ -591,7 +591,7 @@
 
     def descr_classmethod__new__(space, w_subtype, w_function):
         if not space.is_true(space.callable(w_function)):
-            typename = space.type(w_function).getname(space, '?')
+            typename = space.type(w_function).getname(space)
             raise operationerrfmt(space.w_TypeError,
                                   "'%s' object is not callable", typename)
         instance = space.allocate_instance(ClassMethod, w_subtype)

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
@@ -341,7 +341,7 @@
                 raise operationerrfmt(
                     space.w_TypeError,
                     "sequence item %d: expected string, %s "
-                    "found", i, space.type(w_s).getname(space, '?'))
+                    "found", i, space.type(w_s).getname(space))
             reslen += len(space.str_w(w_s))
         reslen += len(self) * (len(list_w) - 1)
         sb = StringBuilder(reslen)

diff --git a/pypy/objspace/std/typetype.py b/pypy/objspace/std/typetype.py
--- a/pypy/objspace/std/typetype.py
+++ b/pypy/objspace/std/typetype.py
@@ -54,7 +54,7 @@
     if not isinstance(w_type, W_TypeObject):
         raise operationerrfmt(space.w_TypeError,
                               "X is not a type object (%s)",
-                              space.type(w_type).getname(space, '?'))
+                              space.type(w_type).getname(space))
     return w_type
 
 # ____________________________________________________________
@@ -114,7 +114,7 @@
         raise operationerrfmt(space.w_TypeError,
                               "can only assign tuple to %s.__bases__, not %s",
                               w_type.name,
-                              space.type(w_value).getname(space, '?'))
+                              space.type(w_value).getname(space))
     newbases_w = space.fixedview(w_value)
     if len(newbases_w) == 0:
         raise operationerrfmt(space.w_TypeError,
@@ -137,8 +137,8 @@
         raise operationerrfmt(space.w_TypeError,
                            "__bases__ assignment: '%s' object layout"
                            " differs from '%s'",
-                           w_newbestbase.getname(space, '?'),
-                           w_oldbestbase.getname(space, '?'))
+                           w_newbestbase.getname(space),
+                           w_oldbestbase.getname(space))
 
     # invalidate the version_tag of all the current subclasses
     w_type.mutated()

diff --git a/pypy/objspace/std/typeobject.py b/pypy/objspace/std/typeobject.py
--- a/pypy/objspace/std/typeobject.py
+++ b/pypy/objspace/std/typeobject.py
@@ -334,7 +334,7 @@
         if not isinstance(w_subtype, W_TypeObject):
             raise operationerrfmt(space.w_TypeError,
                 "X is not a type object ('%s')",
-                space.type(w_subtype).getname(space, '?'))
+                space.type(w_subtype).getname(space))
         if not space.is_true(space.issubtype(w_subtype, w_self)):
             raise operationerrfmt(space.w_TypeError,
                 "%s.__new__(%s): %s is not a subtype of %s",
@@ -875,7 +875,7 @@
         # explicit error message for this specific case
         raise operationerrfmt(space.w_TypeError,
                               "duplicate base class '%s'",
-                              candidate.getname(space,"?"))
+                              candidate.getname(space))
     while candidate not in cycle:
         cycle.append(candidate)
         nextblockinglist = mro_blockinglist(candidate, orderlists)
@@ -883,7 +883,7 @@
     del cycle[:cycle.index(candidate)]
     cycle.append(candidate)
     cycle.reverse()
-    names = [cls.getname(space, "?") for cls in cycle]
+    names = [cls.getname(space) for cls in cycle]
     raise OperationError(space.w_TypeError,
         space.wrap("cycle among base classes: " + ' < '.join(names)))
 

diff --git a/pypy/interpreter/typedef.py b/pypy/interpreter/typedef.py
--- a/pypy/interpreter/typedef.py
+++ b/pypy/interpreter/typedef.py
@@ -51,7 +51,7 @@
     return space.wrap(compute_identity_hash(w_obj))
 
 def descr__hash__unhashable(space, w_obj):
-    typename = space.type(w_obj).getname(space, '?')
+    typename = space.type(w_obj).getname(space)
     raise operationerrfmt(space.w_TypeError,
                           "'%s' objects are unhashable", typename)
 
@@ -512,7 +512,7 @@
                                   " objects doesn't apply to '%s' object",
                                   self.name,
                                   self.w_cls.name,
-                                  space.type(w_obj).getname(space, '?'))
+                                  space.type(w_obj).getname(space))
     
     def descr_member_get(space, member, w_obj, w_w_cls=None):
         """member.__get__(obj[, type]) -> value
@@ -578,7 +578,7 @@
 def descr_get_dict(space, w_obj):
     w_dict = w_obj.getdict()
     if w_dict is None:
-        typename = space.type(w_obj).getname(space, '?')
+        typename = space.type(w_obj).getname(space)
         raise operationerrfmt(space.w_TypeError,
                               "descriptor '__dict__' doesn't apply to"
                               " '%s' objects", typename)

diff --git a/pypy/objspace/taint.py b/pypy/objspace/taint.py
--- a/pypy/objspace/taint.py
+++ b/pypy/objspace/taint.py
@@ -152,7 +152,7 @@
     """Print some info about the taintedness of an object. For debugging
 purposes only!"""
     if isinstance(w_obj, W_Tainted):
-        info = space.type(w_obj.w_obj).getname(space, '?')
+        info = space.type(w_obj.w_obj).getname(space)
         msg = space.str_w(w_obj.w_obj.getrepr(space, info))
         msg = 'Taint Box %s\n' % msg
         os.write(2, msg)

diff --git a/pypy/objspace/std/objecttype.py b/pypy/objspace/std/objecttype.py
--- a/pypy/objspace/std/objecttype.py
+++ b/pypy/objspace/std/objecttype.py
@@ -9,7 +9,7 @@
 def descr__repr__(space, w_obj):
     w = space.wrap
     w_type = space.type(w_obj)
-    classname = w_type.getname(space, '?')
+    classname = w_type.getname(space)
     w_module = w_type.lookup("__module__")
     if w_module is not None:
         try:
@@ -32,7 +32,7 @@
     if not isinstance(w_newcls, W_TypeObject):
         raise operationerrfmt(space.w_TypeError,
                               "__class__ must be set to new-style class, not '%s' object",
-                              space.type(w_newcls).getname(space, '?'))
+                              space.type(w_newcls).getname(space))
     if not w_newcls.is_heaptype():
         raise OperationError(space.w_TypeError,
                              space.wrap("__class__ assignment: only for heap types"))
@@ -44,7 +44,7 @@
     else:
         raise operationerrfmt(space.w_TypeError,
                               "__class__ assignment: '%s' object layout differs from '%s'",
-                              w_oldcls.getname(space, '?'), w_newcls.getname(space, '?'))
+                              w_oldcls.getname(space), w_newcls.getname(space))
     
 
 def descr__new__(space, w_type, __args__):

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
@@ -30,7 +30,7 @@
         raise operationerrfmt(
             space.w_TypeError,
             "decoder did not return an unicode object (type '%s')",
-            space.type(w_retval).getname(space, '?'))
+            space.type(w_retval).getname(space))
     assert isinstance(w_retval, W_RopeUnicodeObject)
     return w_retval
 

diff --git a/pypy/objspace/descroperation.py b/pypy/objspace/descroperation.py
--- a/pypy/objspace/descroperation.py
+++ b/pypy/objspace/descroperation.py
@@ -30,7 +30,7 @@
 
 def raiseattrerror(space, w_obj, name, w_descr=None):
     w_type = space.type(w_obj)
-    typename = w_type.getname(space, '?')
+    typename = w_type.getname(space)
     if w_descr is None:
         raise operationerrfmt(space.w_AttributeError,
                               "'%s' object has no attribute '%s'",
@@ -138,7 +138,7 @@
             return w_obj.call_args(args)
         w_descr = space.lookup(w_obj, '__call__')
         if w_descr is None:
-            typename = space.type(w_obj).getname(space, '?')
+            typename = space.type(w_obj).getname(space)
             raise operationerrfmt(space.w_TypeError,
                                   "'%s' object is not callable",
                                   typename)
@@ -155,7 +155,7 @@
     def set(space, w_descr, w_obj, w_val):
         w_set = space.lookup(w_descr, '__set__')
         if w_set is None:
-            typename = space.type(w_descr).getname(space, '?')
+            typename = space.type(w_descr).getname(space)
             raise operationerrfmt(space.w_TypeError,
                                   "'%s' object is not a descriptor with set",
                                   typename)
@@ -164,7 +164,7 @@
     def delete(space, w_descr, w_obj):
         w_delete = space.lookup(w_descr, '__delete__')
         if w_delete is None:
-            typename = space.type(w_descr).getname(space, '?')
+            typename = space.type(w_descr).getname(space)
             raise operationerrfmt(space.w_TypeError,
                                   "'%s' object is not a descriptor with delete",
                                   typename)
@@ -191,7 +191,7 @@
     def setattr(space, w_obj, w_name, w_val):
         w_descr = space.lookup(w_obj, '__setattr__')
         if w_descr is None:
-            typename = space.type(w_obj).getname(space, '?')
+            typename = space.type(w_obj).getname(space)
             raise operationerrfmt(space.w_AttributeError,
                                   "'%s' object is readonly",
                                   typename)
@@ -200,7 +200,7 @@
     def delattr(space, w_obj, w_name):
         w_descr = space.lookup(w_obj, '__delattr__')
         if w_descr is None:
-            typename = space.type(w_obj).getname(space, '?')
+            typename = space.type(w_obj).getname(space)
             raise operationerrfmt(space.w_AttributeError,
                                   "'%s' object does not support attribute removal",
                                   typename)
@@ -241,7 +241,7 @@
         if w_descr is None:
             w_descr = space.lookup(w_obj, '__getitem__')
             if w_descr is None:
-                typename = space.type(w_obj).getname(space, '?')
+                typename = space.type(w_obj).getname(space)
                 raise operationerrfmt(space.w_TypeError,
                                       "'%s' object is not iterable",
                                       typename)
@@ -251,7 +251,7 @@
     def next(space, w_obj):
         w_descr = space.lookup(w_obj, 'next')
         if w_descr is None:
-            typename = space.type(w_obj).getname(space, '?')
+            typename = space.type(w_obj).getname(space)
             raise operationerrfmt(space.w_TypeError,
                                   "'%s' object is not an iterator",
                                   typename)
@@ -260,7 +260,7 @@
     def getitem(space, w_obj, w_key):
         w_descr = space.lookup(w_obj, '__getitem__')
         if w_descr is None:
-            typename = space.type(w_obj).getname(space, '?')
+            typename = space.type(w_obj).getname(space)
             raise operationerrfmt(space.w_TypeError,
                                   "'%s' object is not subscriptable",
                                   typename)
@@ -269,7 +269,7 @@
     def setitem(space, w_obj, w_key, w_val):
         w_descr = space.lookup(w_obj, '__setitem__')
         if w_descr is None:
-            typename = space.type(w_obj).getname(space, '?')
+            typename = space.type(w_obj).getname(space)
             raise operationerrfmt(space.w_TypeError,
                               "'%s' object does not support item assignment",
                                   typename)
@@ -278,7 +278,7 @@
     def delitem(space, w_obj, w_key):
         w_descr = space.lookup(w_obj, '__delitem__')
         if w_descr is None:
-            typename = space.type(w_obj).getname(space, '?')
+            typename = space.type(w_obj).getname(space)
             raise operationerrfmt(space.w_TypeError,
                                 "'%s' object does not support item deletion",
                                   typename)
@@ -630,8 +630,8 @@
         w_res = _invoke_binop(space, w_right_impl, w_obj2, w_obj1)
         if w_res is not None:
             return w_res
-        typename1 = w_typ1.getname(space, '?')
-        typename2 = w_typ2.getname(space, '?')
+        typename1 = w_typ1.getname(space)
+        typename2 = w_typ2.getname(space)
         raise operationerrfmt(space.w_TypeError, errormsg,
                               typename1, typename2)
     
@@ -693,7 +693,7 @@
     def unaryop_impl(space, w_obj):
         w_impl = space.lookup(w_obj, specialname)
         if w_impl is None:
-            typename = space.type(w_obj).getname(space, '?')
+            typename = space.type(w_obj).getname(space)
             raise operationerrfmt(space.w_TypeError, errormsg, typename)
         return space.get_and_call_function(w_impl, w_obj)
     return func_with_new_name(unaryop_impl, 'unaryop_%s_impl'%specialname.strip('_'))
@@ -715,7 +715,7 @@
         def %(targetname)s(space, w_obj):
             w_impl = space.lookup(w_obj, %(specialname)r)
             if w_impl is None:
-                typename = space.type(w_obj).getname(space, '?')
+                typename = space.type(w_obj).getname(space)
                 raise operationerrfmt(space.w_TypeError,
                       "unsupported operand type for %(targetname)s(): '%%s'",
                                       typename)
@@ -723,7 +723,7 @@
 
             if %(checker)s: 
                 return w_result
-            typename = space.type(w_result).getname(space, '?')
+            typename = space.type(w_result).getname(space)
             msg = "%(specialname)s returned non-%(targetname)s (type '%%s')"
             raise operationerrfmt(space.w_TypeError, msg, typename)
         assert not hasattr(DescrOperation, %(targetname)r)
@@ -742,7 +742,7 @@
         def %(targetname)s(space, w_obj):
             w_impl = space.lookup(w_obj, %(specialname)r)
             if w_impl is None:
-                typename = space.type(w_obj).getname(space, '?')
+                typename = space.type(w_obj).getname(space)
                 raise operationerrfmt(space.w_TypeError,
                       "unsupported operand type for %(targetname)s(): '%%s'",
                                       typename)
@@ -755,7 +755,7 @@
             except OperationError, e:
                 if not e.match(space, space.w_TypeError):
                     raise
-                typename = space.type(w_result).getname(space, '?')
+                typename = space.type(w_result).getname(space)
                 msg = "%(specialname)s returned non-%(targetname)s (type '%%s')"
                 raise operationerrfmt(space.w_TypeError, msg, typename)
             else:

diff --git a/pypy/objspace/std/ropeobject.py b/pypy/objspace/std/ropeobject.py
--- a/pypy/objspace/std/ropeobject.py
+++ b/pypy/objspace/std/ropeobject.py
@@ -287,7 +287,7 @@
                 raise operationerrfmt(
                     space.w_TypeError,
                     "sequence item %d: expected string, %s "
-                    "found", i, space.type(w_s).getname(space, "?"))
+                    "found", i, space.type(w_s).getname(space))
             assert isinstance(w_s, W_RopeObject)
             node = w_s._node
             l.append(node)

diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -55,7 +55,7 @@
         return False
 
     def setdict(self, space, w_dict):
-        typename = space.type(self).getname(space, '?')
+        typename = space.type(self).getname(space)
         raise operationerrfmt(space.w_TypeError,
                               "attribute '__dict__' of %s objects "
                               "is not writable", typename)
@@ -72,7 +72,7 @@
         raise NotImplementedError("only for interp-level user subclasses "
                                   "from typedef.py")
 
-    def getname(self, space, default):
+    def getname(self, space, default='?'):
         try:
             return space.str_w(space.getattr(self, space.wrap('__name__')))
         except OperationError, e:
@@ -117,7 +117,7 @@
             classname = wrappable_class_name(RequiredClass)
         msg = "'%s' object expected, got '%s' instead"
         raise operationerrfmt(space.w_TypeError, msg,
-            classname, self.getclass(space).getname(space, '?'))
+            classname, self.getclass(space).getname(space))
 
     # used by _weakref implemenation
 
@@ -125,7 +125,7 @@
         return None
 
     def setweakref(self, space, weakreflifeline):
-        typename = space.type(self).getname(space, '?')
+        typename = space.type(self).getname(space)
         raise operationerrfmt(space.w_TypeError,
             "cannot create weak reference to '%s' object", typename)
 
@@ -733,7 +733,7 @@
             msg = "'%s' object expected, got '%s' instead"
             raise operationerrfmt(self.w_TypeError, msg,
                 wrappable_class_name(RequiredClass),
-                w_obj.getclass(self).getname(self, '?'))
+                w_obj.getclass(self).getname(self))
         return obj
     interp_w._annspecialcase_ = 'specialize:arg(1)'
 
@@ -1054,7 +1054,7 @@
                 raise
             msg = "%s must be an integer, not %s"
             raise operationerrfmt(self.w_TypeError, msg,
-                objdescr, self.type(w_obj).getname(self, '?'))
+                objdescr, self.type(w_obj).getname(self))
         try:
             index = self.int_w(w_index)
         except OperationError, err:
@@ -1070,7 +1070,7 @@
                 raise operationerrfmt(
                     w_exception,
                     "cannot fit '%s' into an index-sized "
-                    "integer", self.type(w_obj).getname(self, '?'))
+                    "integer", self.type(w_obj).getname(self))
         else:
             return index
 

diff --git a/pypy/translator/goal/sharedpypy.py b/pypy/translator/goal/sharedpypy.py
--- a/pypy/translator/goal/sharedpypy.py
+++ b/pypy/translator/goal/sharedpypy.py
@@ -38,7 +38,7 @@
             pycode.exec_code(space, w_dict, w_dict)
         except OperationError, e:
             print "OperationError:"
-            print " operror-type: " + e.w_type.getname(space, '?')
+            print " operror-type: " + e.w_type.getname(space)
             print " operror-value: " + space.str_w(space.str(e.get_w_value(space)))
             return 1
         return 0

diff --git a/pypy/objspace/std/unicodetype.py b/pypy/objspace/std/unicodetype.py
--- a/pypy/objspace/std/unicodetype.py
+++ b/pypy/objspace/std/unicodetype.py
@@ -238,7 +238,7 @@
     if not space.is_true(space.isinstance(w_retval, space.w_str)):
         raise operationerrfmt(space.w_TypeError,
             "encoder did not return an string object (type '%s')",
-            space.type(w_retval).getname(space, '?'))
+            space.type(w_retval).getname(space))
     return w_retval
 
 def decode_object(space, w_obj, encoding, errors):
@@ -271,7 +271,7 @@
     if not space.is_true(space.isinstance(w_retval, space.w_unicode)):
         raise operationerrfmt(space.w_TypeError,
             "decoder did not return an unicode object (type '%s')",
-            space.type(w_retval).getname(space, '?'))
+            space.type(w_retval).getname(space))
     return w_retval
 
 def unicode_from_object(space, w_obj):

diff --git a/pypy/objspace/std/transparent.py b/pypy/objspace/std/transparent.py
--- a/pypy/objspace/std/transparent.py
+++ b/pypy/objspace/std/transparent.py
@@ -63,7 +63,7 @@
             return v(space, w_type, w_controller)
     raise operationerrfmt(space.w_TypeError, 
         "'%s' object could not be wrapped (YET)",
-        w_type.getname(space, "?"))
+        w_type.getname(space))
 
 def register_proxyable(space, cls):
     tpdef = cls.typedef

diff --git a/pypy/translator/goal/targetpreimportedpypy.py b/pypy/translator/goal/targetpreimportedpypy.py
--- a/pypy/translator/goal/targetpreimportedpypy.py
+++ b/pypy/translator/goal/targetpreimportedpypy.py
@@ -72,7 +72,7 @@
             ##    con.interact()
             except OperationError, e:
                 debug("OperationError:")
-                debug(" operror-type: " + e.w_type.getname(space, '?'))
+                debug(" operror-type: " + e.w_type.getname(space))
                 debug(" operror-value: " + space.str_w(space.str(e.get_w_value(space))))
                 return 1
         finally:
@@ -82,7 +82,7 @@
                 space.timer.stop("space.finish")
             except OperationError, e:
                 debug("OperationError:")
-                debug(" operror-type: " + e.w_type.getname(space, '?'))
+                debug(" operror-type: " + e.w_type.getname(space))
                 debug(" operror-value: " + space.str_w(space.str(e.get_w_value(space))))
                 return 1
         space.timer.stop("Entrypoint")

diff --git a/pypy/objspace/std/stdtypedef.py b/pypy/objspace/std/stdtypedef.py
--- a/pypy/objspace/std/stdtypedef.py
+++ b/pypy/objspace/std/stdtypedef.py
@@ -146,7 +146,7 @@
 
 def _gettypenames(space, *args_w):
     if args_w:
-        typename = space.type(args_w[-1]).getname(space, '?')
+        typename = space.type(args_w[-1]).getname(space)
         return _gettypenames(space, *args_w[:-1]) + (typename,)
     return ()
 _gettypenames._always_inline_ = True

diff --git a/pypy/objspace/std/objspace.py b/pypy/objspace/std/objspace.py
--- a/pypy/objspace/std/objspace.py
+++ b/pypy/objspace/std/objspace.py
@@ -344,7 +344,7 @@
         else:
             raise operationerrfmt(self.w_TypeError,
                 "%s.__new__(%s): only for the type %s",
-                w_type.name, w_subtype.getname(self, '?'), w_type.name)
+                w_type.name, w_subtype.getname(self), w_type.name)
         return instance
     allocate_instance._annspecialcase_ = "specialize:arg(1)"
 

diff --git a/pypy/translator/goal/targetpypystandalone.py b/pypy/translator/goal/targetpypystandalone.py
--- a/pypy/translator/goal/targetpypystandalone.py
+++ b/pypy/translator/goal/targetpypystandalone.py
@@ -65,7 +65,7 @@
             ##    con.interact()
             except OperationError, e:
                 debug("OperationError:")
-                debug(" operror-type: " + e.w_type.getname(space, '?'))
+                debug(" operror-type: " + e.w_type.getname(space))
                 debug(" operror-value: " + space.str_w(space.str(e.get_w_value(space))))
                 return 1
         finally:
@@ -75,7 +75,7 @@
                 space.timer.stop("space.finish")
             except OperationError, e:
                 debug("OperationError:")
-                debug(" operror-type: " + e.w_type.getname(space, '?'))
+                debug(" operror-type: " + e.w_type.getname(space))
                 debug(" operror-value: " + space.str_w(space.str(e.get_w_value(space))))
                 return 1
         space.timer.stop("Entrypoint")

diff --git a/pypy/interpreter/error.py b/pypy/interpreter/error.py
--- a/pypy/interpreter/error.py
+++ b/pypy/interpreter/error.py
@@ -212,7 +212,7 @@
             w_inst = w_type
             w_instclass = space.exception_getclass(w_inst)
             if not space.exception_is_valid_class_w(w_instclass):
-                instclassname = w_instclass.getname(space, '?')
+                instclassname = w_instclass.getname(space)
                 msg = ("exceptions must be classes, or instances, "
                        "or strings (deprecated), not %s")
                 raise operationerrfmt(space.w_TypeError, msg, instclassname)

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
@@ -18,7 +18,7 @@
     pass
 
 def typed_unwrap_error_msg(space, expected, w_obj):
-    type_name = space.type(w_obj).getname(space, '?')
+    type_name = space.type(w_obj).getname(space)
     return space.wrap("expected %s, got %s object" % (expected, type_name))
 
 def int_w__ANY(space,w_obj):


More information about the Pypy-commit mailing list