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.

Author tcaswell
Recipients tcaswell
Date 2017-08-27.02:38:07
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1503801488.97.0.284675687907.issue31286@psf.upfronthosting.co.za>
In-reply-to
Content
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()
yo
---------------------------------------------------------------------------
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 (https://github.com/pytest-dev/pytest/issues/2674)
History
Date User Action Args
2017-08-27 02:38:09tcaswellsetrecipients: + tcaswell
2017-08-27 02:38:08tcaswellsetmessageid: <1503801488.97.0.284675687907.issue31286@psf.upfronthosting.co.za>
2017-08-27 02:38:08tcaswelllinkissue31286 messages
2017-08-27 02:38:07tcaswellcreate