Issue29600
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 2017-02-19 13:44 by njs, last changed 2022-04-11 14:58 by admin. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 644 | merged | yselivanov, 2017-03-12 16:59 | |
| Messages (4) | |||
|---|---|---|---|
| msg288133 - (view) | Author: Nathaniel Smith (njs) * ![]() |
Date: 2017-02-19 13:44 | |
The following code prints "KeyError()", which is obviously wrong and rather baffling. Just passing an exception object around *as an object* should not trigger implicit exception chaining!
If you replace the async functions with regular functions then it prints "None", as expected.
Checked on 3.5, 3.6, and more-or-less current master -- bug is present in all 3.
------------
async def f():
return ValueError()
async def g():
try:
raise KeyError
except:
value_error = await f()
print(repr(value_error.__context__))
try:
g().send(None)
except StopIteration:
pass
|
|||
| msg289503 - (view) | Author: Yury Selivanov (yselivanov) * ![]() |
Date: 2017-03-12 17:01 | |
What a bizarre bug. Created a PR with a fix. Nathaniel, please put me in a nosy list when you submit issues about generators/coroutines. |
|||
| msg289577 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2017-03-14 10:12 | |
I am wondering how much of other uses of PyErr_SetObject() are affected by similar bugs? |
|||
| msg289583 - (view) | Author: Yury Selivanov (yselivanov) * ![]() |
Date: 2017-03-14 13:38 | |
> I am wondering how much of other uses of PyErr_SetObject() are affected by similar bugs? Only when we use an exception to carry a return value. AFAIK StopIteration is the only such case. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:58:43 | admin | set | github: 73786 |
| 2017-03-14 13:38:14 | yselivanov | set | messages: + msg289583 |
| 2017-03-14 10:12:11 | serhiy.storchaka | set | nosy:
+ serhiy.storchaka messages: + msg289577 |
| 2017-03-12 21:04:58 | yselivanov | set | status: open -> closed type: behavior resolution: fixed stage: resolved |
| 2017-03-12 17:01:30 | yselivanov | set | nosy:
+ yselivanov messages: + msg289503 |
| 2017-03-12 16:59:15 | yselivanov | set | pull_requests: + pull_request533 |
| 2017-02-19 13:44:49 | njs | create | |
