Issue1090

classification
Title: Python modules defined with an __init__.py that are precompiled in a jar do not import.
Type: behaviour Severity: normal
Components: Core Versions: Jython 2.7, Jython 2.2
Milestone:
process
Status: open Resolution: remind
Dependencies: Superseder:
Assigned To: Nosy List: colinhevans, fwierzbicki, jeff.allen
Priority: low Keywords:

Created on 2008-07-31.17:42:00 by colinhevans, last changed 2018-07-11.13:35:29 by jeff.allen.

Files
File name Uploaded Description Edit Remove
jartest.py jeff.allen, 2018-03-21.21:06:02 Demonstration working in 2.7
Messages
msg3375 (view) Author: Colin Evans (colinhevans) Date: 2008-07-31.17:48:47
Here's the setup:

test.jar contents:

ttt/__init__.py
ttt/__init__$py.class

>>> import ttt
<single-top>: ttt= 
*sys-package-mgr*: reading cache, '/Users/colin/dev/test.jar'
import: trying source ./ttt
import: trying precompiled with no source./ttt$py.class
import: trying source entry: ttt/__init__.py from jar/zip file
/Users/colin/dev/test.jar/ttt
import: trying precompiled entry ttt/__init__$py.class from jar/zip file
/Users/colin/dev/test.jar/ttt
>>> dir(ttt)
<single-top>: ttt dir 
['__doc__', '__loader__', '__name__', '__path__']

Note - no error message is returned, but the contents of __init__.py are
not actually imported.  If I omit the __init__$py.class file from the
jar file and only include the source, the module imports correctly.
msg11835 (view) Author: Jeff Allen (jeff.allen) Date: 2018-03-21.21:06:02
I think this works in 2.7.2a1, but have I misunderstood (anyone)?

With the set-up, where each file essentially just prints __file__:

PS iss1090> tree /f /a
Folder PATH listing for volume SYSTEM
Volume serial number is 6076-CBCE
C:.
|   jartest.py
|
\---jar-source
    |   tell.py
    |   tell2.py
    |
    \---sub
            tell3.py
            __init__.py

and the attached program, I can create a JAR and access it as I think is intended:

PS iss1090> jython jartest.py
('jar-source', ['sub'], ['tell.py', 'tell2.py'])
('jar-source\\sub', [], ['tell3.py', '__init__.py'])
compiling jar-source -> mylib :
compiling jar-source\sub -> mylib :
File Name                                             Modified             Size
mylib/tell$py.class                            2018-03-21 20:31:58         2455
mylib/tell2$py.class                           2018-03-21 20:31:58         2458
mylib/sub/__init__$py.class                    2018-03-21 20:31:58         2461
mylib/sub/tell3$py.class                       2018-03-21 20:31:58         2470
Executing module from 'C:\\Users...\\iss1090\\jartest.jar\\mylib\\tell$py.class'
Executing module from 'C:\\Users...\\iss1090\\jartest.jar\\mylib\\tell2$py.class'
Executing module from 'C:\\Users...\\iss1090\\jartest.jar\\mylib\\sub\\__init__$py.class'
Executing module from 'C:\\Users...\\iss1090\\jartest.jar\\mylib\\sub\\tell3$py.class'

This is identical to CPython apart from the full pathname and s/.pyc/$py.class/*. The JAR made has the structure:

PS iss1090> jar -tf jartest.jar
mylib/tell$py.class
mylib/tell2$py.class
mylib/sub/__init__$py.class
mylib/sub/tell3$py.class

So this looks good to me in 2.7, and I think we will not fix any earlier version. Close belatedly?
msg12049 (view) Author: Jeff Allen (jeff.allen) Date: 2018-07-11.13:35:28
Maybe try harder to reproduce ... see #2697.
History
Date User Action Args
2018-07-11 13:35:29jeff.allensetstatus: pending -> open
resolution: fixed -> remind
messages: + msg12049
2018-03-21 21:06:04jeff.allensetstatus: open -> pending
files: + jartest.py
versions: + Jython 2.7
nosy: + jeff.allen
messages: + msg11835
resolution: fixed
2013-02-26 17:15:53fwierzbickisetnosy: + fwierzbicki
versions: + Jython 2.2, - 2.2.1rc1
2008-12-17 19:46:32fwierzbickisetpriority: low
2008-07-31 17:48:47colinhevanssetmessages: + msg3375
2008-07-31 17:42:00colinhevanscreate