Commit ec577d53 authored by Guido van Rossum's avatar Guido van Rossum

Correct sys.path[0] when used stand-alone

parent 974e46cc
......@@ -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__'})
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment