diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2017-02-09 22:49:50 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2017-02-09 22:49:50 (GMT) |
commit | 331bbe6aaa74f8d28f27b79e8c6a0c35dbe9a6ab (patch) | |
tree | 9b5a759d220e3249012b7496affe9ba47e36e240 /Lib | |
parent | 516b98161a0e88fde85145ead571e13394215f8c (diff) | |
download | cpython-331bbe6aaa74f8d28f27b79e8c6a0c35dbe9a6ab.zip cpython-331bbe6aaa74f8d28f27b79e8c6a0c35dbe9a6ab.tar.gz cpython-331bbe6aaa74f8d28f27b79e8c6a0c35dbe9a6ab.tar.bz2 |
Issue #29507: Update test_exceptions
test_unraisable() of test_exceptions expects that PyErr_WriteUnraisable(method)
fails on repr(method).
Before the previous change (7b8df4a5d81d), slot_tp_finalize() called
PyErr_WriteUnraisable() with a PyMethodObject. In this case, repr(method) calls
repr(self) which is BrokenRepr.__repr__() and the calls raises a new exception.
After the previous change, slot_tp_finalize() uses an unbound method: repr() is
called on a regular __del__() method which doesn't call repr(self). repr()
doesn't fail anymore.
PyErr_WriteUnraisable() doesn't call __repr__() anymore, so remove BrokenRepr
unit test.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_exceptions.py | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py index 34265a5..14e0f84 100644 --- a/Lib/test/test_exceptions.py +++ b/Lib/test/test_exceptions.py @@ -1023,27 +1023,20 @@ class ExceptionTests(unittest.TestCase): # The following line is included in the traceback report: raise exc - class BrokenRepr(BrokenDel): - def __repr__(self): - raise AttributeError("repr() is broken") - class BrokenExceptionDel: def __del__(self): exc = BrokenStrException() # The following line is included in the traceback report: raise exc - for test_class in (BrokenDel, BrokenRepr, BrokenExceptionDel): + for test_class in (BrokenDel, BrokenExceptionDel): with self.subTest(test_class): obj = test_class() with captured_stderr() as stderr: del obj report = stderr.getvalue() self.assertIn("Exception ignored", report) - if test_class is BrokenRepr: - self.assertIn("<object repr() failed>", report) - else: - self.assertIn(test_class.__del__.__qualname__, report) + self.assertIn(test_class.__del__.__qualname__, report) self.assertIn("test_exceptions.py", report) self.assertIn("raise exc", report) if test_class is BrokenExceptionDel: |