]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Experimental version writes the command to a file.
authorGuido van Rossum <guido@python.org>
Fri, 24 Jan 1992 01:12:00 +0000 (01:12 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 24 Jan 1992 01:12:00 +0000 (01:12 +0000)
Lib/bdb.py

index 36b0f187a1070eeda340895b88dc31baebd9084f..693387bbe08ac46ec5d72c4e6dd606d7779a0d69 100644 (file)
@@ -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 --------------------