]> granicus.if.org Git - python/commitdiff
Add the "interact" pdb command from pdb++.
authorGeorg Brandl <georg@python.org>
Sat, 4 Dec 2010 11:20:26 +0000 (11:20 +0000)
committerGeorg Brandl <georg@python.org>
Sat, 4 Dec 2010 11:20:26 +0000 (11:20 +0000)
Doc/library/pdb.rst
Lib/pdb.py
Misc/NEWS

index 3ef3696e6c9349eb96cd919e6c1304331c6ec870..db21d1f7c7c2233d369a4ddfa1cd46d0fc8f103f 100644 (file)
@@ -407,6 +407,14 @@ by the local file.
 
    .. versionadded:: 3.2
 
+.. pdbcommand:: interact
+
+   Start an interative interpreter (using the :mod:`code` module) whose global
+   namespace contains all the (global and local) names found in the current
+   scope.
+
+   .. versionadded:: 3.2
+
 .. _debugger-aliases:
 
 .. pdbcommand:: alias [name [command]]
index ad71c81b2033d1a6bb30d1e8505f9e8b859ad423..d6a9a925da017bd74711c045144ff72d4b55e6d0 100755 (executable)
@@ -67,15 +67,16 @@ Debugger commands
 # commands and is appended to __doc__ after the class has been defined.
 
 import sys
-import linecache
 import cmd
 import bdb
 import dis
 import os
 import re
+import code
 import pprint
-import traceback
 import inspect
+import traceback
+import linecache
 
 
 class Restart(Exception):
@@ -1167,6 +1168,16 @@ class Pdb(bdb.Bdb, cmd.Cmd):
         # None of the above...
         self.message(type(value))
 
+    def do_interact(self, arg):
+        """interact
+
+        Start an interative interpreter whose global namespace
+        contains all the (global and local) names found in the current scope.
+        """
+        ns = self.curframe.f_globals.copy()
+        ns.update(self.curframe_locals)
+        code.interact("*interactive*", local=ns)
+
     def do_alias(self, arg):
         """alias [name [command [parameter parameter ...] ]]
         Create an alias called 'name' that executes 'command'.  The
@@ -1342,8 +1353,8 @@ if __doc__ is not None:
         'help', 'where', 'down', 'up', 'break', 'tbreak', 'clear', 'disable',
         'enable', 'ignore', 'condition', 'commands', 'step', 'next', 'until',
         'jump', 'return', 'retval', 'run', 'continue', 'list', 'longlist',
-        'args', 'print', 'pp', 'whatis', 'source', 'alias', 'unalias',
-        'debug', 'quit',
+        'args', 'print', 'pp', 'whatis', 'source', 'interact', 'alias',
+        'unalias', 'debug', 'quit',
     ]
 
     for _command in _help_order:
index cbdeb6dfa4f4608849c5042eff0c5d3a25d54b17..3f36425c24fd6c5e5880343679e5df44fdda5e67 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -45,6 +45,8 @@ Core and Builtins
 Library
 -------
 
+- Add the "interact" pdb command.
+
 - Issue #7905: Actually respect the keyencoding parameter to shelve.Shelf.
 
 - Issue #1569291: Speed up array.repeat().