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
import in finally results in SystemError #75467
Comments
Code to reproduce: def import_in_finally_fail():
try:
print('yo')
finally:
import asyncio.queues as aq Results in: In [68]: import_in_finally_fail() SystemError Traceback (most recent call last)
<ipython-input-68-4a6d2efcb22b> in <module>()
----> 1 import_in_finally_fail() /tmp/py2661VBj in import_in_finally_fail() SystemError: 'finally' pops bad exception The exact import does matter, but it needs to be at least 2 modules deep and be aliased. By patching cpython to put what finally pops off the stack in the error message it looks like it is the parent module of the import. This was found via the Matplotlib test suite (ex https://travis-ci.org/matplotlib/matplotlib/jobs/262907186 ) and reported to pytest (pytest-dev/pytest#2674) |
Confirmed. The bug is 3.7 only. |
The regression was introduced in bpo-30024. It was missed a difference between LOAD_ATTR and IMPORT_FROM. LOAD_ATTR replaces the object with the value of the attribute (do not changing the stack pointer). IMPORT_FROM keeps the original module on the stack and pushes the value of the attribute increasing the stack pointer. There are two ways of fixing this issue.
|
PR 3217 implements the first way. It also includes some refactoring. Remove all pyc-files before testing. |
Thank you for your report Thomas! Don't forget to remove pyc-files before re-running the Matplotlib test suite. |
Your welcome! Matplotlib ended up just moving the import out of the finally block once we Tom On Tue, Aug 29, 2017 at 8:50 AM Serhiy Storchaka <report@bugs.python.org>
|
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: