[pypy-svn] r69179 - in pypy/branch/faster-raise/pypy: interpreter module/__builtin__
fijal at codespeak.net
fijal at codespeak.net
Wed Nov 11 16:33:59 CET 2009
Author: fijal
Date: Wed Nov 11 16:33:59 2009
New Revision: 69179
Modified:
pypy/branch/faster-raise/pypy/interpreter/baseobjspace.py
pypy/branch/faster-raise/pypy/interpreter/error.py
pypy/branch/faster-raise/pypy/module/__builtin__/__init__.py
pypy/branch/faster-raise/pypy/module/__builtin__/abstractinst.py
Log:
(arigo, fijal)
Make flow objspace happy, also be slightly more efficient
Modified: pypy/branch/faster-raise/pypy/interpreter/baseobjspace.py
==============================================================================
--- pypy/branch/faster-raise/pypy/interpreter/baseobjspace.py (original)
+++ pypy/branch/faster-raise/pypy/interpreter/baseobjspace.py Wed Nov 11 16:33:59 2009
@@ -835,9 +835,17 @@
# This is slightly less general than the case above, so we prefix
# it with exception_
- def exception_is_valid_class_w(self, w_obj):
- return (self.is_true(self.isinstance(w_obj, self.w_type)) and
- self.is_true(self.issubtype(w_obj, self.w_BaseException)))
+ def exception_is_valid_obj_as_class_w(self, w_obj):
+ if not self.is_true(self.isinstance(w_obj, self.w_type)):
+ return False
+ if not self.full_exceptions:
+ return True
+ return self.is_true(self.issubtype(w_obj, self.w_BaseException))
+
+ def exception_is_valid_class_w(self, w_cls):
+ if not self.full_exceptions:
+ return True
+ return self.is_true(self.issubtype(w_cls, self.w_BaseException))
def exception_getclass(self, w_obj):
return self.type(w_obj)
Modified: pypy/branch/faster-raise/pypy/interpreter/error.py
==============================================================================
--- pypy/branch/faster-raise/pypy/interpreter/error.py (original)
+++ pypy/branch/faster-raise/pypy/interpreter/error.py Wed Nov 11 16:33:59 2009
@@ -177,7 +177,7 @@
while space.is_true(space.isinstance(w_type, space.w_tuple)):
w_type = space.getitem(w_type, space.wrap(0))
- if space.exception_is_valid_class_w(w_type):
+ if space.exception_is_valid_obj_as_class_w(w_type):
# this is for all cases of the form (Class, something)
if space.is_w(w_value, space.w_None):
# raise Type: we assume we have to instantiate Type
Modified: pypy/branch/faster-raise/pypy/module/__builtin__/__init__.py
==============================================================================
--- pypy/branch/faster-raise/pypy/module/__builtin__/__init__.py (original)
+++ pypy/branch/faster-raise/pypy/module/__builtin__/__init__.py Wed Nov 11 16:33:59 2009
@@ -149,6 +149,7 @@
space.abstract_isclass_w = ab.abstract_isclass_w.__get__(space)
space.abstract_getclass = ab.abstract_getclass.__get__(space)
space.exception_is_valid_class_w = ab.exception_is_valid_class_w.__get__(space)
+ space.exception_is_valid_obj_as_class_w = ab.exception_is_valid_obj_as_class_w.__get__(space)
space.exception_getclass = ab.exception_getclass.__get__(space)
space.exception_issubclass_w = ab.exception_issubclass_w.__get__(space)
Modified: pypy/branch/faster-raise/pypy/module/__builtin__/abstractinst.py
==============================================================================
--- pypy/branch/faster-raise/pypy/module/__builtin__/abstractinst.py (original)
+++ pypy/branch/faster-raise/pypy/module/__builtin__/abstractinst.py Wed Nov 11 16:33:59 2009
@@ -156,11 +156,17 @@
# ------------------------------------------------------------
# Exception helpers
-def exception_is_valid_class_w(space, w_obj):
+def exception_is_valid_obj_as_class_w(space, w_obj):
obj = space.interpclass_w(w_obj)
if isinstance(obj, W_ClassObject):
return True
- return BaseObjSpace.exception_is_valid_class_w(space, w_obj)
+ return BaseObjSpace.exception_is_valid_obj_as_class_w(space, w_obj)
+
+def exception_is_valid_class_w(space, w_cls):
+ cls = space.interpclass_w(w_cls)
+ if isinstance(cls, W_ClassObject):
+ return True
+ return BaseObjSpace.exception_is_valid_class_w(space, w_cls)
def exception_getclass(space, w_obj):
obj = space.interpclass_w(w_obj)
More information about the Pypy-commit
mailing list