better sys.path munging when running scripts -- jvr

This commit is contained in:
Just van Rossum 1999-02-01 16:34:08 +00:00
parent 98be47e737
commit a61f4ac14d
1 changed files with 2 additions and 8 deletions

View File

@ -501,12 +501,7 @@ class Editor(W.Window):
dir = os.path.dirname(self.path)
savedir = os.getcwd()
os.chdir(dir)
try:
cwdindex = sys.path.index(os.curdir)
except ValueError:
cwdindex = None
else:
sys.path[cwdindex] = dir
sys.path.insert(0, dir)
else:
cwdindex = None
try:
@ -515,8 +510,7 @@ class Editor(W.Window):
finally:
if self.path:
os.chdir(savedir)
if cwdindex is not None:
sys.path[cwdindex] = os.curdir
del sys.path[0]
def getenvironment(self):
if self.path: