[pypy-svn] r5052 - pypy/trunk/src/pypy/objspace/std
arigo at codespeak.net
arigo at codespeak.net
Fri Jun 11 14:38:23 CEST 2004
Author: arigo
Date: Fri Jun 11 14:38:22 2004
New Revision: 5052
Modified:
pypy/trunk/src/pypy/objspace/std/cpythonobject.py
pypy/trunk/src/pypy/objspace/std/default.py
pypy/trunk/src/pypy/objspace/std/objspace.py
Log:
Improved internal __repr__ and unwrap error message.
Modified: pypy/trunk/src/pypy/objspace/std/cpythonobject.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/cpythonobject.py (original)
+++ pypy/trunk/src/pypy/objspace/std/cpythonobject.py Fri Jun 11 14:38:22 2004
@@ -5,6 +5,7 @@
from pypy.interpreter.function import Function
from stringobject import W_StringObject
from intobject import W_IntObject
+from default import UnwrapError
import sys, operator, types
class W_BuiltinFunctionObject(Function):
@@ -19,11 +20,14 @@
def call(self, w_args, w_kwds):
space = self.space
- args = space.unwrap(w_args)
- kwds = {}
- keys_w = space.unpackiterable(w_kwds)
- for w_key in keys_w:
- kwds[space.unwrap(w_key)] = space.unwrap(space.getitem(w_kwds, w_key))
+ try:
+ args = space.unwrap(w_args)
+ kwds = {}
+ keys_w = space.unpackiterable(w_kwds)
+ for w_key in keys_w:
+ kwds[space.unwrap(w_key)] = space.unwrap(space.getitem(w_kwds, w_key))
+ except UnwrapError, e:
+ raise UnwrapError('calling %s: %s' % (self.cpyfunc, e))
try:
result = apply(self.cpyfunc, args, kwds)
except:
Modified: pypy/trunk/src/pypy/objspace/std/default.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/default.py (original)
+++ pypy/trunk/src/pypy/objspace/std/default.py Fri Jun 11 14:38:22 2004
@@ -216,11 +216,14 @@
# ugh
+class UnwrapError(Exception):
+ pass
+
def unwrap__ANY(space, w_obj):
if isinstance(w_obj, Wrappable):
return w_obj
else:
- raise TypeError, 'cannot unwrap %r' % (w_obj,)
+ raise UnwrapError, 'cannot unwrap %r' % (w_obj,)
register_all(vars())
Modified: pypy/trunk/src/pypy/objspace/std/objspace.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/objspace.py (original)
+++ pypy/trunk/src/pypy/objspace/std/objspace.py Fri Jun 11 14:38:22 2004
@@ -13,11 +13,14 @@
w_self.space = space # XXX not sure this is ever used any more
def __repr__(self):
- return '%s(%s)' % (
+ s = '%s(%s)' % (
self.__class__.__name__,
#', '.join(['%s=%r' % keyvalue for keyvalue in self.__dict__.items()])
getattr(self, 'name', '')
)
+ if hasattr(self, 'w__class__'):
+ s += ' instance of %s' % self.w__class__
+ return '<%s>' % s
# delegation priorities
PRIORITY_SAME_TYPE = 2 # converting between several impls of the same type
More information about the Pypy-commit
mailing list