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
c2c8fe12
Commit
c2c8fe12
authored
Dec 01, 2016
by
Yury Selivanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #28843: Fix asyncio C Task to handle exceptions __traceback__.
parent
c349374e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
0 deletions
+22
-0
Lib/test/test_asyncio/test_tasks.py
Lib/test/test_asyncio/test_tasks.py
+15
-0
Misc/NEWS
Misc/NEWS
+2
-0
Modules/_asynciomodule.c
Modules/_asynciomodule.c
+5
-0
No files found.
Lib/test/test_asyncio/test_tasks.py
View file @
c2c8fe12
...
...
@@ -1952,6 +1952,21 @@ class BaseTaskTests:
self
.
assertFalse
(
gather_task
.
cancelled
())
self
.
assertEqual
(
gather_task
.
result
(),
[
42
])
def
test_exception_traceback
(
self
):
# See http://bugs.python.org/issue28843
@
asyncio
.
coroutine
def
foo
():
1
/
0
@
asyncio
.
coroutine
def
main
():
task
=
self
.
new_task
(
self
.
loop
,
foo
())
yield
# skip one loop iteration
self
.
assertIsNotNone
(
task
.
exception
().
__traceback__
)
self
.
loop
.
run_until_complete
(
main
())
@
mock
.
patch
(
'asyncio.base_events.logger'
)
def
test_error_in_call_soon
(
self
,
m_log
):
def
call_soon
(
callback
,
*
args
):
...
...
Misc/NEWS
View file @
c2c8fe12
...
...
@@ -24,6 +24,8 @@ Library
- Issue #24142: Reading a corrupt config file left configparser in an
invalid state. Original patch by Florian Höch.
- Issue #28843: Fix asyncio C Task to handle exceptions __traceback__.
Tools/Demos
-----------
...
...
Modules/_asynciomodule.c
View file @
c2c8fe12
...
...
@@ -1042,6 +1042,8 @@ FutureIter_throw(futureiterobject *self, PyObject *args)
if
(
PyExceptionClass_Check
(
type
))
{
PyErr_NormalizeException
(
&
type
,
&
val
,
&
tb
);
/* No need to call PyException_SetTraceback since we'll be calling
PyErr_Restore for `type`, `val`, and `tb`. */
}
else
if
(
PyExceptionInstance_Check
(
type
))
{
if
(
val
)
{
PyErr_SetString
(
PyExc_TypeError
,
...
...
@@ -2003,6 +2005,9 @@ task_step_impl(TaskObj *task, PyObject *exc)
if
(
!
ev
||
!
PyObject_TypeCheck
(
ev
,
(
PyTypeObject
*
)
et
))
{
PyErr_NormalizeException
(
&
et
,
&
ev
,
&
tb
);
}
if
(
tb
!=
NULL
)
{
PyException_SetTraceback
(
ev
,
tb
);
}
o
=
future_set_exception
((
FutureObj
*
)
task
,
ev
);
if
(
!
o
)
{
/* An exception in Task.set_exception() */
...
...
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