summaryrefslogtreecommitdiff
path: root/Lib/pdb.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1996-09-10 17:39:34 +0000
committerGuido van Rossum <guido@python.org>1996-09-10 17:39:34 +0000
commitff031d05e3e03629a9e255249adb32373cb45d4b (patch)
treee525248674e6801d8e608b166cae3891ad33dcd0 /Lib/pdb.py
parentdb4192d09a1e8012a1e4cff2da76999cc1a1cf82 (diff)
downloadcpython-ff031d05e3e03629a9e255249adb32373cb45d4b.tar.gz
Correct sys.path[0] when used stand-alone
Diffstat (limited to 'Lib/pdb.py')
-rwxr-xr-xLib/pdb.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/Lib/pdb.py b/Lib/pdb.py
index 60b3412566..62927a3730 100755
--- a/Lib/pdb.py
+++ b/Lib/pdb.py
@@ -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__'})