diff options
author | Guido van Rossum <guido@python.org> | 1995-02-27 13:13:40 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1995-02-27 13:13:40 (GMT) |
commit | 5e38b6fda1d4e2822ac72e1f643f251bd0f3175b (patch) | |
tree | 4a86a9f4be277dd15b9957a15d768a7b09966e3e /Lib/bdb.py | |
parent | 051ab123b465685e714668099c0a6dd86de5673b (diff) | |
download | cpython-5e38b6fda1d4e2822ac72e1f643f251bd0f3175b.zip cpython-5e38b6fda1d4e2822ac72e1f643f251bd0f3175b.tar.gz cpython-5e38b6fda1d4e2822ac72e1f643f251bd0f3175b.tar.bz2 |
handle class exceptions; added runeval; made runctx obsolete
Diffstat (limited to 'Lib/bdb.py')
-rw-r--r-- | Lib/bdb.py | 37 |
1 files changed, 30 insertions, 7 deletions
@@ -270,36 +270,59 @@ class Bdb: # Basic Debugger # The following two methods can be called by clients to use # a debugger to debug a statement, given as a string. - def run(self, cmd): - import __main__ - dict = __main__.__dict__ - self.runctx(cmd, dict, dict) + def run(self, cmd, globals=None, locals=None): + if globals is None: + import __main__ + globals = __main__.__dict__ + if locals is None: + locals = globals + self.reset() + sys.settrace(self.trace_dispatch) + try: + try: + exec cmd + '\n' in globals, locals + except BdbQuit: + pass + finally: + self.quitting = 1 + sys.settrace(None) - def runctx(self, cmd, globals, locals): + def runeval(self, expr, globals=None, locals=None): + if globals is None: + import __main__ + globals = __main__.__dict__ + if locals is None: + locals = globals self.reset() sys.settrace(self.trace_dispatch) try: try: - exec(cmd + '\n', globals, locals) + return eval(expr + '\n', globals, locals) except BdbQuit: pass finally: self.quitting = 1 sys.settrace(None) + def runctx(self, cmd, globals, locals): + # B/W compatibility + self.run(cmd, globals, locals) + # This method is more useful to debug a single function call. def runcall(self, func, *args): self.reset() sys.settrace(self.trace_dispatch) + res = None try: try: - apply(func, args) + res = apply(func, args) except BdbQuit: pass finally: self.quitting = 1 sys.settrace(None) + return res def set_trace(): |