[pypy-commit] pypy translation-cleanup: Use FlowingError for non-constant excepts.
rlamy
noreply at buildbot.pypy.org
Fri Sep 21 19:53:06 CEST 2012
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: translation-cleanup
Changeset: r57459:24d010e8202f
Date: 2012-09-21 18:52 +0100
http://bitbucket.org/pypy/pypy/changeset/24d010e8202f/
Log: Use FlowingError for non-constant excepts.
* Add failing test (raises the wrong exception)
diff --git a/pypy/objspace/flow/objspace.py b/pypy/objspace/flow/objspace.py
--- a/pypy/objspace/flow/objspace.py
+++ b/pypy/objspace/flow/objspace.py
@@ -188,7 +188,7 @@
try:
check_class = self.unwrap(w_check_class)
except UnwrapException:
- raise Exception, "non-constant except guard"
+ raise FlowingError(self.frame, "Non-constant except guard.")
if check_class in (NotImplementedError, AssertionError):
raise FlowingError(self.frame,
"Catching %s is not valid in RPython" % check_class.__name__)
diff --git a/pypy/objspace/flow/test/test_objspace.py b/pypy/objspace/flow/test/test_objspace.py
--- a/pypy/objspace/flow/test/test_objspace.py
+++ b/pypy/objspace/flow/test/test_objspace.py
@@ -980,6 +980,16 @@
self.codetest(f)
assert 'div(5, 0)' in str(excinfo.value)
+ @py.test.mark.xfail
+ def test_nonconstant_except(self):
+ def f(exc_cls):
+ try:
+ raise AttributeError
+ except exc_cls:
+ pass
+ with py.test.raises(FlowingError):
+ self.codetest(f)
+
def test__flowspace_rewrite_directly_as_(self):
def g(x):
pass
More information about the pypy-commit
mailing list