Issue1671373

classification
Title: A "$_PyInner.class" file in a package causes import to fail
Type: Severity: normal
Components: Core Versions:
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: alanfx, cgroves
Priority: normal Keywords:

Created on 2007-03-01.01:58:01 by alanfx, last changed 2007-04-23.04:16:02 by cgroves.

Messages
msg1517 (view) Author: Alan Field (alanfx) Date: 2007-03-01.01:58:01
A "$_PyInner.class" file can be generated by jythonc. In Jython 2.2 beta 1 if you have one of these files in a Python package directory, then the directory is treated as a Java package and none of the "__init__.py" files in the directory are executed. (I do not believe that a directory that contains both ".class" files and ".py" will successfully import either.)

The problem is the org.python.core. PathPackageManager.PackageExistsFileFilter.accept() method. This method is called with each file in the directory. If the file name ends with ".class", then the directory is treated as a Java package. If the file name ends with either ".py" or "$py.class", then the directory is treated as a Python package. The accept method needs to also test to see if the file name ends with "$_PyInner.class" like this:

        public boolean accept(File dir, String name) { 
            if (name.endsWith(".py") || name.endsWith("$py.class") || name.endsWith("$_PyInner.class")) { 
                this.python = true; 
            } else if (name.endsWith(".class")) { 
                this.java = true; 
            } 
            return false; 
        } 

msg1518 (view) Author: Charlie Groves (cgroves) Date: 2007-04-23.04:16:02
Thanks!  Committed in r3181.
History
Date User Action Args
2007-03-01 01:58:01alanfxcreate