Author: Amaury Forgeot d'Arc <[email protected]>
Branch: py3.3
Changeset: r82026:9067ded8c01d
Date: 2016-02-01 09:39 +0100
http://bitbucket.org/pypy/pypy/changeset/9067ded8c01d/
Log: Add a more complex test for e.__context__, directly from CPython.
diff --git a/pypy/interpreter/error.py b/pypy/interpreter/error.py
--- a/pypy/interpreter/error.py
+++ b/pypy/interpreter/error.py
@@ -350,8 +350,9 @@
self.normalize_exception(space)
w_value = self.get_w_value(space)
w_last = last_exception.get_w_value(space)
- w_context = setup_context(space, w_value, w_last, lazy=True)
- space.setattr(w_value, space.wrap('__context__'), w_context)
+ if not space.is_w(w_value, w_last):
+ w_context = setup_context(space, w_value, w_last, lazy=True)
+ space.setattr(w_value, space.wrap('__context__'), w_context)
def setup_context(space, w_exc, w_last, lazy=False):
diff --git a/pypy/interpreter/test/test_raise.py
b/pypy/interpreter/test/test_raise.py
--- a/pypy/interpreter/test/test_raise.py
+++ b/pypy/interpreter/test/test_raise.py
@@ -408,6 +408,25 @@
except:
func()
+ def testCauseSyntax(self):
+ """
+ try:
+ try:
+ try:
+ raise TypeError
+ except Exception:
+ raise ValueError from None
+ except ValueError as exc:
+ assert exc.__cause__ is None
+ assert exc.__suppress_context__ is True
+ exc.__suppress_context__ = False
+ raise exc
+ except ValueError as exc:
+ e = exc
+ assert e.__cause__ is None
+ assert e.__suppress_context__ is False
+ assert isinstance(e.__context__, TypeError)
+ """
class AppTestTraceback:
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit