]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Correct sys.path[0] when used stand-alone
authorGuido van Rossum <guido@python.org>
Tue, 10 Sep 1996 17:39:34 +0000 (17:39 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 10 Sep 1996 17:39:34 +0000 (17:39 +0000)
Lib/pdb.py

index 60b34125665c328c13930fcc45fbb249fdfe7e17..62927a373002236bf9c6cc499407d2f23b097ae7 100755 (executable)
@@ -496,13 +496,16 @@ def help():
 # When invoked as main program, invoke the debugger on a script
 if __name__=='__main__':
        import sys
+       import os
        if not sys.argv[1:]:
                print "usage: pdb.py scriptfile [arg] ..."
                sys.exit(2)
 
-       # Get the module name and function name, if present
-       filename = sys.argv[1]
+       filename = sys.argv[1]  # Get script filename
+
+       del sys.argv[0]         # Hide "pdb.py" from argument list
 
-       del sys.argv[0]
+       # Insert script directory in front of module search path
+       sys.path.insert(0, os.path.dirname(filename))
 
        run('execfile(' + `filename` + ')', {'__name__': '__main__'})