[Python-checkins] r70998 - in python/trunk: Lib/pdb.py Misc/NEWS

georg.brandl python-checkins at python.org
Wed Apr 1 23:54:21 CEST 2009


Author: georg.brandl
Date: Wed Apr  1 23:54:21 2009
New Revision: 70998

Log:
In Pdb, stop assigning values to __builtin__._ which interferes with the one commonly installed by gettext.

Modified:
   python/trunk/Lib/pdb.py
   python/trunk/Misc/NEWS

Modified: python/trunk/Lib/pdb.py
==============================================================================
--- python/trunk/Lib/pdb.py	(original)
+++ python/trunk/Lib/pdb.py	Wed Apr  1 23:54:21 2009
@@ -194,6 +194,12 @@
         self.cmdloop()
         self.forget()
 
+    def displayhook(self, obj):
+        """Custom displayhook for the exec in default(), which prevents
+        assignment of the _ variable in the builtins.
+        """
+        print obj
+
     def default(self, line):
         if line[:1] == '!': line = line[1:]
         locals = self.curframe.f_locals
@@ -202,13 +208,16 @@
             code = compile(line + '\n', '<stdin>', 'single')
             save_stdout = sys.stdout
             save_stdin = sys.stdin
+            save_displayhook = sys.displayhook
             try:
                 sys.stdin = self.stdin
                 sys.stdout = self.stdout
+                sys.displayhook = self.displayhook
                 exec code in globals, locals
             finally:
                 sys.stdout = save_stdout
                 sys.stdin = save_stdin
+                sys.displayhook = save_displayhook
         except:
             t, v = sys.exc_info()[:2]
             if type(t) == type(''):

Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS	(original)
+++ python/trunk/Misc/NEWS	Wed Apr  1 23:54:21 2009
@@ -202,6 +202,9 @@
 Library
 -------
 
+- In Pdb, prevent the reassignment of __builtin__._ by sys.displayhook on
+  printing out values.
+
 - Issue #4572: added SEEK_* symbolic constants to io module.
 
 - Issue #1665206 (partially): Move imports in cgitb to the top of the module


More information about the Python-checkins mailing list