Issue1714

classification
Title: import error not being raised
Type: Severity: normal
Components: Core Versions: 2.5.2rc
Milestone:
process
Status: closed Resolution: invalid
Dependencies: Superseder:
Assigned To: Nosy List: larry, pjenvey
Priority: Keywords:

Created on 2011-03-01.10:28:08 by larry, last changed 2011-03-02.04:16:32 by larry.

Files
File name Uploaded Description Edit Remove
unnamed larry, 2011-03-02.04:16:32
Messages
msg6422 (view) Author: (larry) Date: 2011-03-01.10:28:08
A python program with the following fragment...

try:
    import psyco            # a specializing [runtime] compiler
    have_psyco = True       # for 32-bit compilations of Python
    print 'psyco enabled'
except:
    have_psyco = False

should have failed and have_psyco set to False.  It wasn't.  Instead a module named "psyco" was created with a single element "__name__" set to "psyco".  Later a conditioned dependency based on have_psyco being True caused a crash.  

The same program ran just fine after the offending psyco-based statements were commented out.
msg6423 (view) Author: Philip Jenvey (pjenvey) Date: 2011-03-01.17:07:14
I can't reproduce this. What does print psyco.__file__ show you? My guess is you have a psyco.py file somewhere in your sys.path that is being picked up when you aren't expecting it to be
msg6424 (view) Author: (larry) Date: 2011-03-01.20:14:55
On Mar 1, 2011, at 9:07 AM, Philip Jenvey wrote:

> 
> Philip Jenvey <pjenvey@underboss.org> added the comment:
> 
> I can't reproduce this. What does print psyco.__file__ show you? My guess is you have a psyco.py file somewhere in your sys.path that is being picked up when you aren't expecting it to be
> 
> ----------
> components: +Core -Jythonc compiler
> nosy: +pjenvey
> resolution:  -> invalid
> status: open -> closed
> 
> _______________________________________
> Jython tracker <report@bugs.jython.org>
> <http://bugs.jython.org/issue1714>
> _______________________________________
msg6425 (view) Author: (larry) Date: 2011-03-01.20:15:58
Sorry, I hit send prematurely. 

I'm preparing a more definitive scenario.

On Mar 1, 2011, at 9:07 AM, Philip Jenvey wrote:

> 
> Philip Jenvey <pjenvey@underboss.org> added the comment:
> 
> I can't reproduce this. What does print psyco.__file__ show you? My guess is you have a psyco.py file somewhere in your sys.path that is being picked up when you aren't expecting it to be
> 
> ----------
> components: +Core -Jythonc compiler
> nosy: +pjenvey
> resolution:  -> invalid
> status: open -> closed
> 
> _______________________________________
> Jython tracker <report@bugs.jython.org>
> <http://bugs.jython.org/issue1714>
> _______________________________________
msg6426 (view) Author: (larry) Date: 2011-03-01.23:02:05
On Mar 1, 2011, at 9:07 AM, Philip Jenvey wrote:
Philip Jenvey <pjenvey@underboss.org> added the comment:
> My guess is you have a psyco.py file somewhere in your sys.path that is being picked up when you aren't expecting it to be

Hmmmm...  Good thought so I took an extensive look at PATH and sys.path.  No Joy.

Looking then at CLASSPATH I see I had it defined to be ".:..:"  ...a leftover artifact from some testing I did a year or two ago.  When I removed ".." (parent dir) everything worked as expected.

What's curious is the parent dir is a dir of [uninteresting] dirs.  So then how could Java/Jython pick up anything related to psyco with just ".."?  

...unless Jython sets/resets the working directory for some reason and the parent dir at that point has a file with psyco in it.  (I do have such files in various places in my file system but none should be "interesting".)

For now I can get along with CLASSPATH=. but if I or anybody else were to use a relative pathname in their CLASSPATH they could conceivably get unexpected results?  Dunno, just a theory.  

So thank you Philip for the hint.  I'm good-to-go, but this does raise the question: Does Jython/Java change working dirs (internally/on-the-fly) and then use CLASSPATH from that point making relative paths problematic?

Larry
msg6427 (view) Author: (larry) Date: 2011-03-02.04:16:32
On Mar 1, 2011, at 3:13 PM, Larry Bugbee wrote:

> PS:
> 
>> What does print psyco.__file__ show you?
> 
> When I had the problem, I did a dir(psyco).  There was no entry for "__file__".  The only entry was " __name__" and psyco.__name__ had the value "psyco".  
> 
>
History
Date User Action Args
2011-03-02 04:16:32larrysetfiles: + unnamed
messages: + msg6427
2011-03-01 23:02:06larrysetmessages: + msg6426
2011-03-01 20:15:58larrysetmessages: + msg6425
2011-03-01 20:14:55larrysetmessages: + msg6424
2011-03-01 17:07:14pjenveysetstatus: open -> closed
resolution: invalid
messages: + msg6423
components: + Core, - Jythonc compiler
nosy: + pjenvey
2011-03-01 10:28:08larrycreate