[issue28131] assert statements missed when loaded by zipimporter

2017-03-31 Thread Donald Stufft

Changes by Donald Stufft :


--
pull_requests: +887

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28131] assert statements missed when loaded by zipimporter

2016-09-13 Thread Berker Peksag

Berker Peksag added the comment:

Thanks for the report and for the reviews!

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28131] assert statements missed when loaded by zipimporter

2016-09-13 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 7bec326972f5 by Berker Peksag in branch '3.5':
Issue #28131: Fix a regression in zipimport's compile_source()
https://hg.python.org/cpython/rev/7bec326972f5

New changeset 7a6c0c4e6072 by Berker Peksag in branch '3.6':
Issue #28131: Merge from 3.5
https://hg.python.org/cpython/rev/7a6c0c4e6072

New changeset 873760b02024 by Berker Peksag in branch 'default':
Issue #28131: Merge from 3.6
https://hg.python.org/cpython/rev/873760b02024

--
nosy: +python-dev

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28131] assert statements missed when loaded by zipimporter

2016-09-13 Thread Benjamin Peterson

Benjamin Peterson added the comment:

lgtm

--
nosy: +benjamin.peterson

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28131] assert statements missed when loaded by zipimporter

2016-09-13 Thread Berker Peksag

Berker Peksag added the comment:

Here is a patch with a test case.

--
keywords: +patch
nosy: +berker.peksag
stage:  -> patch review
type:  -> behavior
Added file: http://bugs.python.org/file44647/issue28131.diff

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28131] assert statements missed when loaded by zipimporter

2016-09-13 Thread Steve Dower

Changes by Steve Dower :


--
nosy: +larry
versions: +Python 3.5

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28131] assert statements missed when loaded by zipimporter

2016-09-13 Thread Steve Dower

Steve Dower added the comment:

Bah, that's meant to be a -1 in that change, not 1. I must have typo'd when 
moving from the default branch to put it in 3.5.

Anyone's welcome to fix it, or I'll get it when I have time for CPython work.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28131] assert statements missed when loaded by zipimporter

2016-09-13 Thread Xiang Zhang

Xiang Zhang added the comment:

This is introduced in 663a62bcf9c9. The compile optimize flag is opened in the 
change.

--
nosy: +steve.dower, xiang.zhang

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28131] assert statements missed when loaded by zipimporter

2016-09-13 Thread Gregory P. Smith

Gregory P. Smith added the comment:

from the zip:

>>> dis.dis(mod.test)
  3   0 LOAD_GLOBAL  0 (print)
  2 LOAD_FAST0 (val)
  4 CALL_FUNCTION1
  6 POP_TOP
  8 LOAD_CONST   0 (None)
 10 RETURN_VALUE

from the filesystem:
>>> dis.dis(mod.test)
  2   0 LOAD_FAST0 (val)
  2 POP_JUMP_IF_TRUE 8
  4 LOAD_GLOBAL  0 (AssertionError)
  6 RAISE_VARARGS1

  3 >>8 LOAD_GLOBAL  1 (print)
 10 LOAD_FAST0 (val)
 12 CALL_FUNCTION1
 14 POP_TOP
 16 LOAD_CONST   0 (None)
 18 RETURN_VALUE

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28131] assert statements missed when loaded by zipimporter

2016-09-13 Thread Gregory P. Smith

Gregory P. Smith added the comment:

This shouldn't be happening and makes no sense.  It looks like the assert 
statement was removed at import code compilation time given the pdb trace with 
it from a zip file vs with it outside of a zip file:


>>> pdb.run('mod.test(False)')
> (1)()
(Pdb) n
False
--Return--
> (1)()->None
(Pdb) n
>>> pdb.run('mod.test(False)')
> (1)()->None
(Pdb) s
--Call--
> oss/cpython/build/mod.zip/mod.py(1)test()
-> def test(val):
(Pdb) s
> oss/cpython/build/mod.zip/mod.py(3)test()
-> print(val)
(Pdb) s
False
--Return--
> oss/cpython/build/mod.zip/mod.py(3)test()->None
-> print(val)
(Pdb) s
--Return--
> (1)()->None
(Pdb) s
> oss/cpython/default/Lib/bdb.py(435)run()
-> self.quitting = True
(Pdb) s
>>> 

vs no zip file:

>>> pdb.run('mod.test(False)')
> (1)()
(Pdb) s
--Call--
> oss/cpython/build/mod.py(1)test()
-> def test(val):
(Pdb) s
> oss/cpython/build/mod.py(2)test()
-> assert(val)
(Pdb) s
AssertionError
> oss/cpython/build/mod.py(2)test()
-> assert(val)
(Pdb) s
--Return--
> oss/cpython/build/mod.py(2)test()->None
-> assert(val)
(Pdb) s
AssertionError
> (1)()
(Pdb) s
--Return--
> (1)()->None
(Pdb) s
AssertionError
> oss/cpython/default/Lib/bdb.py(431)run()
-> exec(cmd, globals, locals)
(Pdb) s
> oss/cpython/default/Lib/bdb.py(432)run()
-> except BdbQuit:
(Pdb) s
> oss/cpython/default/Lib/bdb.py(435)run()
-> self.quitting = True
(Pdb) s
Traceback (most recent call last):
  File "", line 1, in 
  File "oss/cpython/default/Lib/pdb.py", line 1568, in run
Pdb().run(statement, globals, locals)
  File "oss/cpython/default/Lib/bdb.py", line 431, in run
exec(cmd, globals, locals)
  File "", line 1, in 
  File "oss/cpython/build/mod.py", line 2, in test
assert(val)
AssertionError

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28131] assert statements missed when loaded by zipimporter

2016-09-13 Thread Brett Cannon

Brett Cannon added the comment:

I've added Greg and Thomas in case they have any ideas as they have looked at 
zipimport more recently than I have.

--
nosy: +gregory.p.smith, twouters

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28131] assert statements missed when loaded by zipimporter

2016-09-13 Thread Jason R. Coombs

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__

>>> 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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com