[pypy-svn] r50591 - pypy/branch/applevel-ctypes2/pypy/interpreter
arigo at codespeak.net
arigo at codespeak.net
Mon Jan 14 14:26:52 CET 2008
Author: arigo
Date: Mon Jan 14 14:26:52 2008
New Revision: 50591
Modified:
pypy/branch/applevel-ctypes2/pypy/interpreter/baseobjspace.py
Log:
(fijal, arigo)
Don't segfault trying to print error messages about interp_w(BaseClass)
if the BaseClass has no typedef attribute.
Modified: pypy/branch/applevel-ctypes2/pypy/interpreter/baseobjspace.py
==============================================================================
--- pypy/branch/applevel-ctypes2/pypy/interpreter/baseobjspace.py (original)
+++ pypy/branch/applevel-ctypes2/pypy/interpreter/baseobjspace.py Mon Jan 14 14:26:52 2008
@@ -100,7 +100,7 @@
def descr_call_mismatch(self, space, opname, RequiredClass, args):
msg = "'%s' object expected, got '%s' instead" % (
- RequiredClass.typedef.name,
+ wrappable_class_name(RequiredClass),
self.getclass(space).getname(space, '?'))
raise OperationError(space.w_TypeError, space.wrap(msg))
@@ -164,6 +164,15 @@
class DescrMismatch(Exception):
pass
+def wrappable_class_name(Class):
+ try:
+ return Class.typedef.name
+ except AttributeError:
+ return 'internal subclass of %s' % (Class.__name__,)
+wrappable_class_name._annspecialcase_ = 'specialize:memo'
+
+# ____________________________________________________________
+
class ObjSpace(object):
"""Base class for the interpreter-level implementations of object spaces.
http://codespeak.net/pypy/dist/pypy/doc/objspace.html"""
@@ -570,8 +579,8 @@
obj = self.interpclass_w(w_obj)
if not isinstance(obj, RequiredClass): # or obj is None
msg = "'%s' object expected, got '%s' instead" % (
- RequiredClass.typedef.name,
- w_obj.getclass(self).getname(self, '?'))
+ wrappable_class_name(RequiredClass),
+ w_obj.getclass(self).getname(self, '?'))
raise OperationError(self.w_TypeError, self.wrap(msg))
return obj
interp_w._annspecialcase_ = 'specialize:arg(1)'
More information about the Pypy-commit
mailing list