[New-bugs-announce] [issue31286] import in finally results in SystemError

Thomas Caswell report at bugs.python.org
Sat Aug 26 22:38:08 EDT 2017

New submission from Thomas Caswell:

Code to reproduce:

def import_in_finally_fail():
        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 (https://github.com/pytest-dev/pytest/issues/2674)

components: Interpreter Core
messages: 300911
nosy: tcaswell
priority: normal
severity: normal
status: open
title: import in finally results in SystemError
type: crash
versions: Python 3.7

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list