[New-bugs-announce] [issue28131] assert statements missed when loaded by zipimporter

Jason R. Coombs report at bugs.python.org
Tue Sep 13 12:19:15 EDT 2016


New submission from Jason R. Coombs:

Grabbing the recently released Python 3.6.0b1, I tried running one of my test suites, but found that some assertions were failing to assert when the package was loaded as a zip file (such as with pytest-runner installed dependencies). I distilled the issue to this:

$ cat > mod.py
def test(val):
        assert(val)
        print(val)
$ zip mod.zip mod.py
updating: mod.py (deflated 20%)
$ rm mod.py
$ python
Python 3.6.0b1 (v3.6.0b1:5b0ca4ed5e2f, Sep 12 2016, 09:24:46) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path.append('mod.zip')
>>> import mod
>>> mod.test(False)
False
>>> mod.__loader__
<zipimporter object "mod.zip">
>>> sys.flags.optimize
0

I would have expected the call to mod.test to have raised an AssertionError, and on Python 3.5 it does.

I searched the what's new and didn't see anything advertising this change, so I suspect it's an unintentional regression.

I'm including Brett for his familiarity with importlib, but welcome re-assignment.

If I can do more to help, let me know.

----------
components: Library (Lib)
messages: 276296
nosy: brett.cannon, jason.coombs, ned.deily
priority: release blocker
severity: normal
status: open
title: assert statements missed when loaded by zipimporter
versions: Python 3.6, Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28131>
_______________________________________


More information about the New-bugs-announce mailing list