STINNER Victor <vstin...@redhat.com> added the comment:

Another example of hook: hook_file.patch logs unraisable exception into 
~/unraisable.txt. Patch written for my latest PR 13187 (with the new 'msg' 
parameter).

Example of output when running the Python test suite (using multiple processes! 
./python -m test -j0 -r):
----------
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Exception ignored in: <function TestContext.test_3611.<locals>.C.__del__ at 
0x7f0d5c71eb00>
ZeroDivisionError: division by zero
Traceback (most recent call last):
  ...
  File "/home/vstinner/prog/python/master/Lib/test/test_raise.py", line 463, in 
test_3611
    f()
  File "/home/vstinner/prog/python/master/Lib/test/test_raise.py", line 456, in 
f
    del x
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Exception ignored in: <generator object f at 0x7f023c985050>
RuntimeError: generator ignored GeneratorExit
Traceback (most recent call last):
  ...
  File "/home/vstinner/prog/python/master/Lib/test/test_generators.py", line 
2207, in test_main
    support.run_doctest(test_generators, verbose)
  ...
  File "<doctest test.test_generators.__test__.coroutine[80]>", line 1, in 
<module>
    del g
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Exception ignored in: <http.client.HTTPResponse object at 0x7f2afefd00e0>
ValueError: I/O operation on closed file.
Traceback (most recent call last):
  ...
  File "/home/vstinner/prog/python/master/Lib/test/test_urllib.py", line 421, 
in test_invalid_redirect
    urlopen("http://python.org/";)
  File "/home/vstinner/prog/python/master/Lib/unittest/case.py", line 237, in 
__exit__
    traceback.clear_frames(tb)
  File "/home/vstinner/prog/python/master/Lib/traceback.py", line 220, in 
clear_frames
    tb.tb_frame.clear()
----------

IMHO such hook is more convenient than killing the process with SIGABRT ;-)

----------
Added file: https://bugs.python.org/file48329/hook_file.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue36829>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to