New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
__exit__ silences the active exception #47082
Comments
If a context manager is used within exception handling block, the active try: |
This problem was introduced by r62847. |
Note that the problem is not related to "with", but with nested try: OTOH, python has always had poor support for nested exceptions; tried try: This does not happen if the two lines with KeyError are moved in another |
I've just discovered that the patch in r62847 doesn't clean up the |
Raising priority. |
As Amaury said, lexically nested exception handlers make re-raising try: With the slight inconvenience that the "raise e" line will be appended If we want bare "raise" statements to work as expected after a nested |
Small typo in the snippet above, this should obviously read: try: |
Just found another funny example. This one fails also before r62847. def except_yield():
try:
raise Exception("foo")
except:
yield 1
raise
list(except_yield()) In Py3k (with or without r62487), we get "RuntimeError: No active |
Fixed in r64121. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: