summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1992-01-24 01:12:00 (GMT)
committerGuido van Rossum <guido@python.org>1992-01-24 01:12:00 (GMT)
commit177dd80799cf16b7cee634f82fa12d86b2873f6d (patch)
treef945c7fe4a77e5d41f26ecd2c7d35bd0741ee1c8 /Lib
parentbabe2bf8f45090cef6072e6e6bb38b32afa9423e (diff)
downloadcpython-177dd80799cf16b7cee634f82fa12d86b2873f6d.zip
cpython-177dd80799cf16b7cee634f82fa12d86b2873f6d.tar.gz
cpython-177dd80799cf16b7cee634f82fa12d86b2873f6d.tar.bz2
Experimental version writes the command to a file.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/bdb.py18
1 files changed, 15 insertions, 3 deletions
diff --git a/Lib/bdb.py b/Lib/bdb.py
index 36b0f18..693387b 100644
--- a/Lib/bdb.py
+++ b/Lib/bdb.py
@@ -6,6 +6,7 @@
# and 'wdb', a window-oriented debugger.
# And of course... you can roll your own!
+
import sys
BdbQuit = 'bdb.BdbQuit' # Exception to give up completely
@@ -220,9 +221,8 @@ class Bdb: # Basic Debugger
# a debugger to debug a statement, given as a string.
def run(self, cmd):
- import __main__
- dict = __main__.__dict__
- self.runctx(cmd, dict, dict)
+ modname = self.writetempfile(cmd)
+ self.runctx('import ' + modname + '\n', {}, {})
def runctx(self, cmd, globals, locals):
self.reset()
@@ -237,6 +237,18 @@ class Bdb: # Basic Debugger
del sys.trace
# XXX What to do if the command finishes normally?
+ def writetempfile(self, cmd):
+ import os
+ modname = 'bdb' + `os.getpid()`
+ filename = '/tmp/' + modname + '.py'
+ f = open(filename, 'w')
+ f.write(cmd + '\n')
+ f.close()
+ import sys
+ if sys.modules.has_key(modname): del sys.modules[modname]
+ if '/tmp' not in sys.path: sys.path.insert(0, '/tmp')
+ return modname
+
# -------------------- testing --------------------