summaryrefslogtreecommitdiffstats
path: root/Lib/bdb.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1995-02-27 13:13:40 (GMT)
committerGuido van Rossum <guido@python.org>1995-02-27 13:13:40 (GMT)
commit5e38b6fda1d4e2822ac72e1f643f251bd0f3175b (patch)
tree4a86a9f4be277dd15b9957a15d768a7b09966e3e /Lib/bdb.py
parent051ab123b465685e714668099c0a6dd86de5673b (diff)
downloadcpython-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.py37
1 files changed, 30 insertions, 7 deletions
diff --git a/Lib/bdb.py b/Lib/bdb.py
index 0d139d4..6d0536d 100644
--- a/Lib/bdb.py
+++ b/Lib/bdb.py
@@ -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():