New submission from Nathaniel Smith:

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

----------
components: Interpreter Core
messages: 288133
nosy: njs
priority: normal
severity: normal
status: open
title: Returning an exception object from a coroutine triggers implicit 
exception chaining?!?
versions: Python 3.5, Python 3.6, Python 3.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29600>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to