[Python-checkins] cpython: Merge 3.6 (issue #28843)
yury.selivanov
python-checkins at python.org
Thu Dec 1 11:38:02 EST 2016
https://hg.python.org/cpython/rev/a21a8943c59e
changeset: 105406:a21a8943c59e
parent: 105404:8f258245c391
user: Yury Selivanov <yury at magic.io>
date: Thu Dec 01 11:37:47 2016 -0500
summary:
Merge 3.6 (issue #28843)
files:
Lib/test/test_asyncio/test_tasks.py | 15 +++++++++++++++
Modules/_asynciomodule.c | 5 +++++
2 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/Lib/test/test_asyncio/test_tasks.py b/Lib/test/test_asyncio/test_tasks.py
--- a/Lib/test/test_asyncio/test_tasks.py
+++ b/Lib/test/test_asyncio/test_tasks.py
@@ -1952,6 +1952,21 @@
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):
diff --git a/Modules/_asynciomodule.c b/Modules/_asynciomodule.c
--- a/Modules/_asynciomodule.c
+++ b/Modules/_asynciomodule.c
@@ -1041,6 +1041,8 @@
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,
@@ -2001,6 +2003,9 @@
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() */
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list