[pypy-svn] r10370 - in pypy/branch/pypy-normalize-exception: interpreter objspace/flow
arigo at codespeak.net
arigo at codespeak.net
Wed Apr 6 19:16:43 CEST 2005
Author: arigo
Date: Wed Apr 6 19:16:43 2005
New Revision: 10370
Modified:
pypy/branch/pypy-normalize-exception/interpreter/baseobjspace.py
pypy/branch/pypy-normalize-exception/interpreter/error.py
pypy/branch/pypy-normalize-exception/interpreter/pyframe.py
pypy/branch/pypy-normalize-exception/objspace/flow/objspace.py
Log:
Generates much smaller graphs on except:.
Modified: pypy/branch/pypy-normalize-exception/interpreter/baseobjspace.py
==============================================================================
--- pypy/branch/pypy-normalize-exception/interpreter/baseobjspace.py (original)
+++ pypy/branch/pypy-normalize-exception/interpreter/baseobjspace.py Wed Apr 6 19:16:43 2005
@@ -272,6 +272,9 @@
else:
return self.w_True
+ def abstract_getclass(self, w_obj):
+ return self.getattr(w_obj, self.wrap('__class__'))
+
def eval(self, expression, w_globals, w_locals):
"NOT_RPYTHON: For internal debugging."
Modified: pypy/branch/pypy-normalize-exception/interpreter/error.py
==============================================================================
--- pypy/branch/pypy-normalize-exception/interpreter/error.py (original)
+++ pypy/branch/pypy-normalize-exception/interpreter/error.py Wed Apr 6 19:16:43 2005
@@ -136,9 +136,9 @@
if space.is_w(w_value, space.w_None):
# raise Type: we assume we have to instantiate Type
w_value = space.call_function(w_type)
- w_type = space.getattr(w_value, space.wrap('__class__'))
+ w_type = space.abstract_getclass(w_value)
else:
- w_valuetype = space.getattr(w_value, space.wrap('__class__'))
+ w_valuetype = space.abstract_getclass(w_value)
if space.is_true(space.abstract_issubclass(w_valuetype,
w_type)):
# raise Type, Instance: let etype be the exact type of value
@@ -152,18 +152,12 @@
else:
# raise Type, X: assume X is the constructor argument
w_value = space.call_function(w_type, w_value)
- w_type = space.getattr(w_value, space.wrap('__class__'))
+ w_type = space.abstract_getclass(w_value)
elif space.full_exceptions and space.is_w(space.type(w_type),
space.w_str):
# XXX warn -- deprecated
- if (space.is_w(w_value, space.w_None) or
- space.is_w(space.type(w_value), space.w_str)):
- pass # ok
- else:
- raise OperationError(space.w_TypeError,
- space.wrap("string exceptions can only "
- "have a string value"))
+ pass
else:
# raise X: we assume that X is an already-built instance
@@ -172,7 +166,7 @@
space.wrap("instance exception may not "
"have a separate value"))
w_value = w_type
- w_type = space.getattr(w_value, space.wrap('__class__'))
+ w_type = space.abstract_getclass(w_value)
if space.full_exceptions:
# for the sake of language consistency we should not allow
# things like 'raise 1', but it is probably fine (i.e.
Modified: pypy/branch/pypy-normalize-exception/interpreter/pyframe.py
==============================================================================
--- pypy/branch/pypy-normalize-exception/interpreter/pyframe.py (original)
+++ pypy/branch/pypy-normalize-exception/interpreter/pyframe.py Wed Apr 6 19:16:43 2005
@@ -400,7 +400,8 @@
except OperationError, operationerr:
# exception while normalizing the exception!
# you get an exception, just not the one you might expect...
- operationerr.normalize_exception(frame.space)
+ if frame.space.full_exceptions:
+ operationerr.normalize_exception(frame.space)
# the stack setup is slightly different than in CPython:
# instead of the traceback, we store the unroller object,
# wrapped.
Modified: pypy/branch/pypy-normalize-exception/objspace/flow/objspace.py
==============================================================================
--- pypy/branch/pypy-normalize-exception/objspace/flow/objspace.py (original)
+++ pypy/branch/pypy-normalize-exception/objspace/flow/objspace.py Wed Apr 6 19:16:43 2005
@@ -217,6 +217,9 @@
def abstract_isclass(self, w_obj):
return self.isinstance(w_obj, self.w_type)
+ def abstract_getclass(self, w_obj):
+ return self.type(w_obj)
+
def build_flow(self, func, constargs={}):
"""
More information about the Pypy-commit
mailing list