This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Created on 2013-08-18 23:07 by doughellmann, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
set_traceback.patch georg.brandl, 2013-10-13 19:24 review
atexit_tracebacks.patch pitrou, 2013-10-13 19:27
atexit_tracebacks2.patch pitrou, 2013-10-13 19:42
Messages (8)
msg195586 - (view) Author: Doug Hellmann (doughellmann) * (Python committer) Date: 2013-08-18 23:07
Under python 2 when an atexit callback raised an exception the full traceback was displayed. Under python 3, only the summary of the exception is shown. Input file: import atexit def exit_with_exception(message): raise RuntimeError(message) atexit.register(exit_with_exception, 'Registered first') atexit.register(exit_with_exception, 'Registered second') Python 2: $ python2.7 source/atexit/atexit_exception.py Error in atexit._run_exitfuncs: Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/atexit.py", line 24, in _run_exitfuncs func(*targs, **kargs) File "source/atexit/atexit_exception.py", line 36, in exit_with_exception raise RuntimeError(message) RuntimeError: Registered second Error in atexit._run_exitfuncs: Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/atexit.py", line 24, in _run_exitfuncs func(*targs, **kargs) File "source/atexit/atexit_exception.py", line 36, in exit_with_exception raise RuntimeError(message) RuntimeError: Registered first Error in sys.exitfunc: Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/atexit.py", line 24, in _run_exitfuncs func(*targs, **kargs) File "source/atexit/atexit_exception.py", line 36, in exit_with_exception raise RuntimeError(message) RuntimeError: Registered first Python 3: $ python3.3 source/atexit/atexit_exception.py Error in atexit._run_exitfuncs: RuntimeError: Registered second Error in atexit._run_exitfuncs: RuntimeError: Registered first
msg199768 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2013-10-13 19:24
The attached patch fixes two instances of PyErr_Display being called without the traceback properly set on the exception object.
msg199770 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-10-13 19:27
Attached patch does the setting in PyErr_Display (which is an undocumented API, thus presumably private), and adds a test for atexit.
msg199771 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2013-10-13 19:29
With your patch, can the SetTraceback in PyErr_Print be removed? Or should PyErr_Display only set the tb if there is none on the object already?
msg199772 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-10-13 19:33
> With your patch, can the SetTraceback in PyErr_Print be removed? I don't think so. PyErr_Print() calls sys.excepthook, which can be overriden with custom code. > Or should PyErr_Display only set the tb if there is none on the > object already? Well, why not!
msg199776 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-10-13 19:42
Updated patch.
msg199781 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-10-13 19:54
New changeset 19ce90930e8b by Antoine Pitrou in branch '3.3': Issue #18776: atexit callbacks now display their full traceback when they raise an exception. http://hg.python.org/cpython/rev/19ce90930e8b New changeset c13ef65f3dcf by Antoine Pitrou in branch 'default': Issue #18776: atexit callbacks now display their full traceback when they raise an exception. http://hg.python.org/cpython/rev/c13ef65f3dcf
msg199782 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-10-13 19:55
Since it's a regression from 2.7, I chose to commit it as a bugfix (to 3.3 and 3.4).
History
Date User Action Args
2022-04-11 14:57:49adminsetgithub: 62976
2013-10-13 19:55:27pitrousetstatus: open -> closed
type: enhancement -> behavior
messages: + msg199782

resolution: fixed
stage: patch review -> resolved
2013-10-13 19:54:30python-devsetnosy: + python-dev
messages: + msg199781
2013-10-13 19:42:08pitrousetfiles: + atexit_tracebacks2.patch

stage: needs patch -> patch review
messages: + msg199776
versions: + Python 3.3
2013-10-13 19:33:11pitrousetmessages: + msg199772
2013-10-13 19:29:24georg.brandlsetmessages: + msg199771
2013-10-13 19:27:34pitrousetfiles: + atexit_tracebacks.patch

messages: + msg199770
2013-10-13 19:24:05georg.brandlsetfiles: + set_traceback.patch

nosy: + georg.brandl, pitrou
messages: + msg199768

keywords: + patch
2013-08-23 18:58:45pitrousetstage: patch review -> needs patch
2013-08-18 23:11:22pitrousetkeywords: + easy
stage: patch review
type: enhancement
components: + Library (Lib)
versions: - Python 3.1, Python 3.2, Python 3.3
2013-08-18 23:07:59doughellmanncreate