Author: Amaury Forgeot d'Arc <[email protected]>
Branch: py3k
Changeset: r58352:6c43fd71ae59
Date: 2012-10-22 08:28 +0200
http://bitbucket.org/pypy/pypy/changeset/6c43fd71ae59/
Log: In "raise exc from cause", cause can be a exception type, and must
be normalized: call it to create an instance.
diff --git a/pypy/interpreter/astcompiler/test/test_compiler.py
b/pypy/interpreter/astcompiler/test/test_compiler.py
--- a/pypy/interpreter/astcompiler/test/test_compiler.py
+++ b/pypy/interpreter/astcompiler/test/test_compiler.py
@@ -817,7 +817,17 @@
def f():
try:
raise TypeError() from ValueError()
- except TypeError:
+ except TypeError as e:
+ assert isinstance(e.__cause__, ValueError)
+ return 42
+ """
+ yield self.st, test, "f()", 42
+ test = """if 1:
+ def f():
+ try:
+ raise TypeError from ValueError
+ except TypeError as e:
+ assert isinstance(e.__cause__, ValueError)
return 42
"""
yield self.st, test, "f()", 42
diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py
--- a/pypy/interpreter/pyopcode.py
+++ b/pypy/interpreter/pyopcode.py
@@ -484,6 +484,8 @@
w_value = w_cause = space.w_None
if nbargs == 2:
w_cause = self.popvalue()
+ if space.exception_is_valid_obj_as_class_w(w_cause):
+ w_cause = space.call_function(w_cause)
w_value = self.popvalue()
if space.exception_is_valid_obj_as_class_w(w_value):
w_type = w_value
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit