summaryrefslogtreecommitdiffstats
path: root/Lib/pdb.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2008-01-15 17:59:29 (GMT)
committerGuido van Rossum <guido@python.org>2008-01-15 17:59:29 (GMT)
commitcad3724352562a3a9b951b30c0b98b8f40c09dcf (patch)
tree8acd8d716d018d6fdb63ef298a638de4e4348d58 /Lib/pdb.py
parent7b1e917e419c234627a88319cc30d10844d12039 (diff)
downloadcpython-cad3724352562a3a9b951b30c0b98b8f40c09dcf.zip
cpython-cad3724352562a3a9b951b30c0b98b8f40c09dcf.tar.gz
cpython-cad3724352562a3a9b951b30c0b98b8f40c09dcf.tar.bz2
Issue #1786 (by myself): pdb should use its own stdin/stdout around an
exec call and when creating a recursive instance.
Diffstat (limited to 'Lib/pdb.py')
-rwxr-xr-xLib/pdb.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/Lib/pdb.py b/Lib/pdb.py
index 468b1d3..e2ace87 100755
--- a/Lib/pdb.py
+++ b/Lib/pdb.py
@@ -199,7 +199,13 @@ class Pdb(bdb.Bdb, cmd.Cmd):
globals = self.curframe.f_globals
try:
code = compile(line + '\n', '<stdin>', 'single')
- exec code in globals, locals
+ try:
+ sys.stdin = self.stdin
+ sys.stdout = self.stdout
+ exec code in globals, locals
+ finally:
+ sys.stdout = save_stdout
+ sys.stdin = save_stdin
except:
t, v = sys.exc_info()[:2]
if type(t) == type(''):
@@ -659,7 +665,7 @@ class Pdb(bdb.Bdb, cmd.Cmd):
sys.settrace(None)
globals = self.curframe.f_globals
locals = self.curframe.f_locals
- p = Pdb()
+ p = Pdb(self.completekey, self.stdin, self.stdout)
p.prompt = "(%s) " % self.prompt.strip()
print >>self.stdout, "ENTERING RECURSIVE DEBUGGER"
sys.call_tracing(p.run, (arg, globals, locals))