Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
5392cb22
Commit
5392cb22
authored
Oct 13, 2013
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #18776: atexit callbacks now display their full traceback when they raise an exception.
parent
eafc59ae
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
0 deletions
+32
-0
Lib/test/test_atexit.py
Lib/test/test_atexit.py
+19
-0
Misc/NEWS
Misc/NEWS
+3
-0
Python/pythonrun.c
Python/pythonrun.c
+10
-0
No files found.
Lib/test/test_atexit.py
View file @
5392cb22
...
@@ -74,6 +74,25 @@ class TestCase(unittest.TestCase):
...
@@ -74,6 +74,25 @@ class TestCase(unittest.TestCase):
self
.
assertRaises
(
ZeroDivisionError
,
atexit
.
_run_exitfuncs
)
self
.
assertRaises
(
ZeroDivisionError
,
atexit
.
_run_exitfuncs
)
self
.
assertIn
(
"ZeroDivisionError"
,
self
.
stream
.
getvalue
())
self
.
assertIn
(
"ZeroDivisionError"
,
self
.
stream
.
getvalue
())
def
test_print_tracebacks
(
self
):
# Issue #18776: the tracebacks should be printed when errors occur.
def
f
():
1
/
0
# one
def
g
():
1
/
0
# two
def
h
():
1
/
0
# three
atexit
.
register
(
f
)
atexit
.
register
(
g
)
atexit
.
register
(
h
)
self
.
assertRaises
(
ZeroDivisionError
,
atexit
.
_run_exitfuncs
)
stderr
=
self
.
stream
.
getvalue
()
self
.
assertEqual
(
stderr
.
count
(
"ZeroDivisionError"
),
3
)
self
.
assertIn
(
"# one"
,
stderr
)
self
.
assertIn
(
"# two"
,
stderr
)
self
.
assertIn
(
"# three"
,
stderr
)
def
test_stress
(
self
):
def
test_stress
(
self
):
a
=
[
0
]
a
=
[
0
]
def
inc
():
def
inc
():
...
...
Misc/NEWS
View file @
5392cb22
...
@@ -76,6 +76,9 @@ Core and Builtins
...
@@ -76,6 +76,9 @@ Core and Builtins
Library
Library
-------
-------
- Issue #18776: atexit callbacks now display their full traceback when they
raise an exception.
- Issue #17827: Add the missing documentation for ``codecs.encode`` and
- Issue #17827: Add the missing documentation for ``codecs.encode`` and
``codecs.decode``.
``codecs.decode``.
...
...
Python/pythonrun.c
View file @
5392cb22
...
@@ -1880,6 +1880,16 @@ PyErr_Display(PyObject *exception, PyObject *value, PyObject *tb)
...
@@ -1880,6 +1880,16 @@ PyErr_Display(PyObject *exception, PyObject *value, PyObject *tb)
{
{
PyObject
*
seen
;
PyObject
*
seen
;
PyObject
*
f
=
PySys_GetObject
(
"stderr"
);
PyObject
*
f
=
PySys_GetObject
(
"stderr"
);
if
(
PyExceptionInstance_Check
(
value
)
&&
tb
!=
NULL
&&
PyTraceBack_Check
(
tb
))
{
/* Put the traceback on the exception, otherwise it won't get
displayed. See issue #18776. */
PyObject
*
cur_tb
=
PyException_GetTraceback
(
value
);
if
(
cur_tb
==
NULL
)
PyException_SetTraceback
(
value
,
tb
);
else
Py_DECREF
(
cur_tb
);
}
if
(
f
==
Py_None
)
{
if
(
f
==
Py_None
)
{
/* pass */
/* pass */
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment