diff options
author | Guido van Rossum <guido@python.org> | 1996-09-10 17:39:34 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1996-09-10 17:39:34 (GMT) |
commit | ec577d53a989efd96dd2d43d2f749ff92a5e4e8d (patch) | |
tree | ea5f808e4cba405efe7acf507dfe3c84fb224ecd /Lib/pdb.py | |
parent | 974e46cc5e7d4c8cab7b0490965020929bf26588 (diff) | |
download | cpython-ec577d53a989efd96dd2d43d2f749ff92a5e4e8d.zip cpython-ec577d53a989efd96dd2d43d2f749ff92a5e4e8d.tar.gz cpython-ec577d53a989efd96dd2d43d2f749ff92a5e4e8d.tar.bz2 |
Correct sys.path[0] when used stand-alone
Diffstat (limited to 'Lib/pdb.py')
-rwxr-xr-x | Lib/pdb.py | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -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__'}) |