]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
better sys.path munging when running scripts -- jvr
authorJust van Rossum <just@lettererror.com>
Mon, 1 Feb 1999 16:34:08 +0000 (16:34 +0000)
committerJust van Rossum <just@lettererror.com>
Mon, 1 Feb 1999 16:34:08 +0000 (16:34 +0000)
Mac/Tools/IDE/PyEdit.py

index f885d049e31168b28c7c58d96cbe9893028502c0..8536b946ce91029183a4f917c19ba1a320f4faea 100644 (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: