Title: "import" picks up directories that don't contain an
Type: behaviour Severity: major
Components: Core Versions: Jython 2.7, Jython 2.5
Status: open Resolution: remind
Dependencies: Superseder:
Assigned To: Nosy List: fwierzbicki, pjenvey, teratorn
Priority: normal Keywords:

Created on 2008-10-04.07:07:22 by teratorn, last changed 2013-02-27.17:29:24 by fwierzbicki.

msg3641 (view) Author: Eric P. Mangold (teratorn) Date: 2008-10-04.07:07:21
In a particular project that I work on I have a normal, non-package 
directory that happens to have the same name as a package that I need 
to use from Jython.

It seems that since this directory is in the current working directory 
when I start jython it is masking the real package of the same name.

I imagine this should be easy to reproduce. Let me know if I can help.
msg3709 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2008-10-27.18:22:16
I'm actually having a little trouble reproducing this.  What version of
Jython are you using?  Also, could you describe a minimal directory
structure that causes trouble?  I tried an empty "foo" directory with a
sibling, and importing foo from another .py file worked.  This is
using trunk on OS X.
msg3716 (view) Author: Eric P. Mangold (teratorn) Date: 2008-10-28.16:42:28
I just updated SVN and built jython. Still exhibiting the same behavior:

Archimedes ~/code % mkdir foo2
Archimedes ~/code % jython/src/shell/jython
Jython 2.5a3+ (trunk:5523M, Oct 28 2008, 11:33:53) 
[Java HotSpot(TM) Server VM (Sun Microsystems Inc.)] on java1.5.0_15
Type "help", "copyright", "credits" or "license" for more information.
>>> import foo2
>>> foo2.__file__
>>> dir(foo2)
>>> foo2.__name__

I would expect "import foo2" to raise an ImportError since there isn't 
any such package.
msg3818 (view) Author: Philip Jenvey (pjenvey) Date: 2008-11-23.02:47:45
Doh, this is due to our PathPackageManager attempting to handle Java 
packages that might only contain other packages:

We should make this packageExists() check consider an empty directory to 
not be a package -- but we would have the same issue for an empty 
directory containing another directory. I'm not sure we can handle this 
without some false positives
msg3835 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2008-11-23.14:10:00
I wonder if it would be too expensive to check to see if we are looking
at an entire empty directory tree?
msg7836 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2013-02-27.17:29:24
I suspect this will get resolved for better or worse when we implement for Jython 3.
Date User Action Args
2013-02-27 17:29:24fwierzbickisetresolution: remind
messages: + msg7836
versions: + Jython 2.5, Jython 2.7, - 2.5alpha3
2009-03-30 16:49:51fwierzbickisetassignee: fwierzbicki ->
2009-03-14 14:26:26fwierzbickisetpriority: normal
2008-11-23 14:10:00fwierzbickisetmessages: + msg3835
2008-11-23 02:47:46pjenveysetnosy: + pjenvey
messages: + msg3818
2008-10-28 16:42:28teratornsetmessages: + msg3716
2008-10-27 18:22:17fwierzbickisetmessages: + msg3709
2008-10-27 18:20:19fwierzbickisetassignee: fwierzbicki
nosy: + fwierzbicki
2008-10-04 07:07:22teratorncreate