[ python-Bugs-693416 ] 2.3a2 import after os.chdir difference

SourceForge.net noreply at sourceforge.net
Sat Jun 5 16:00:28 EDT 2004


Bugs item #693416, was opened at 2003-02-26 04:42
Message generated for change (Comment added) made by insomnike
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=693416&group_id=5470

Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: James P Rutledge (jrut)
Assigned to: Nobody/Anonymous (nobody)
Summary: 2.3a2 import after os.chdir difference

Initial Comment:
In Python 2.3a2 in interactive mode an import after an
os.chdir imports the module in the new current
directory after the os.chdir.

This is the same as Python 2.2.2 does both in
interactive and non-interactive mode.

In Python 2.3a2 in non-interactive mode an import after
an os.chdir does not import the module in the new
current directory after the os.chdir.  Instead it
attempts to import a module (if present) by that name
in the previous current directory before the os.chdir.
If there is not a module by that name in the previous
current directory, there is an ImportError exception.

The above results are on a Debian Linux system using an
Intel 32 bit processor.

No PYTHONSTARTUP environment variable was set.
No PYTHONPATH environment variable was set.


----------------------------------------------------------------------

Comment By: Aaron Brady (insomnike)
Date: 2004-06-05 20:00

Message:
Logged In: YES 
user_id=1057404

Right, I'm nearly sure that this is the behaviour that we want.

When run interactively, the first item in sys.path is '',
but when run from a script, it is the path to the directory
that the script lives in. If we reverted to the 2.2.2
behaviour, multi-module scripts couldn't use os.chdir() for
fear of randomly breaking imports.

----------------------------------------------------------------------

Comment By: James P Rutledge (jrut)
Date: 2003-02-26 14:31

Message:
Logged In: YES 
user_id=720847

Additional Info -- I have now tried more than one
os.chdir before the import in non-interactive mode and
found that the words "previous current directory" in
the original description should be more accurately
expressed as "ORIGINAL current directory."


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=693416&group_id=5470



More information about the Python-bugs-list mailing list