mirror of
https://github.com/python/cpython.git
synced 2025-10-17 20:28:43 +00:00
gh-129354: Use PyErr_FormatUnraisable() function (#129523)
Replace PyErr_WriteUnraisable() with PyErr_FormatUnraisable(). Update tests: * test_coroutines * test_exceptions * test_generators * test_struct
This commit is contained in:
parent
dc804ffb2f
commit
a25042e6d2
7 changed files with 42 additions and 17 deletions
|
@ -2664,14 +2664,18 @@ Our ill-behaved code should be invoked during GC:
|
|||
>>> with support.catch_unraisable_exception() as cm:
|
||||
... g = f()
|
||||
... next(g)
|
||||
... gen_repr = repr(g)
|
||||
... del g
|
||||
...
|
||||
... cm.unraisable.err_msg == (f'Exception ignored while closing '
|
||||
... f'generator {gen_repr}')
|
||||
... cm.unraisable.exc_type == RuntimeError
|
||||
... "generator ignored GeneratorExit" in str(cm.unraisable.exc_value)
|
||||
... cm.unraisable.exc_traceback is not None
|
||||
True
|
||||
True
|
||||
True
|
||||
True
|
||||
|
||||
And errors thrown during closing should propagate:
|
||||
|
||||
|
@ -2776,10 +2780,12 @@ to test.
|
|||
... invoke("del failed")
|
||||
...
|
||||
>>> with support.catch_unraisable_exception() as cm:
|
||||
... l = Leaker()
|
||||
... del l
|
||||
... leaker = Leaker()
|
||||
... del_repr = repr(type(leaker).__del__)
|
||||
... del leaker
|
||||
...
|
||||
... cm.unraisable.object == Leaker.__del__
|
||||
... cm.unraisable.err_msg == (f'Exception ignored while '
|
||||
... f'calling deallocator {del_repr}')
|
||||
... cm.unraisable.exc_type == RuntimeError
|
||||
... str(cm.unraisable.exc_value) == "del failed"
|
||||
... cm.unraisable.exc_traceback is not None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue