summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Doc/library/pdb.rst6
-rw-r--r--Doc/whatsnew/3.4.rst16
-rwxr-xr-xLib/pdb.py8
-rw-r--r--Lib/test/test_pdb.py9
-rw-r--r--Misc/NEWS3
5 files changed, 31 insertions, 11 deletions
diff --git a/Doc/library/pdb.rst b/Doc/library/pdb.rst
index f4e37ac..66a78d0 100644
--- a/Doc/library/pdb.rst
+++ b/Doc/library/pdb.rst
@@ -41,7 +41,7 @@ of the debugger is::
.. versionchanged:: 3.3
Tab-completion via the :mod:`readline` module is available for commands and
command arguments, e.g. the current global and local names are offered as
- arguments of the ``print`` command.
+ arguments of the ``p`` command.
:file:`pdb.py` can also be invoked as a script to debug other scripts. For
example::
@@ -309,7 +309,7 @@ by the local file.
``end`` to terminate the commands. An example::
(Pdb) commands 1
- (com) print some_variable
+ (com) p some_variable
(com) end
(Pdb)
@@ -409,7 +409,7 @@ by the local file.
.. pdbcommand:: pp expression
- Like the :pdbcmd:`print` command, except the value of the expression is
+ Like the :pdbcmd:`p` command, except the value of the expression is
pretty-printed using the :mod:`pprint` module.
.. pdbcommand:: whatis expression
diff --git a/Doc/whatsnew/3.4.rst b/Doc/whatsnew/3.4.rst
index ed4ea17..373f8de 100644
--- a/Doc/whatsnew/3.4.rst
+++ b/Doc/whatsnew/3.4.rst
@@ -302,6 +302,22 @@ descriptors or a Windows handle:
* :func:`os.get_handle_inheritable`, :func:`os.set_handle_inheritable`
+pdb
+---
+
+The ``print`` command has been removed from :mod:`pdb`, restoring access to the
+``print`` function.
+
+Rationale: Python2's ``pdb`` did not have a ``print`` command; instead,
+entering ``print`` executed the ``print`` statement. In Python3 ``print`` was
+mistakenly made an alias for the pdb :pdbcmd:`p` command. ``p``, however,
+prints the ``repr`` of its argument, not the ``str`` like the Python2 ``print``
+command did. Worse, the Python3 ``pdb print`` command shadowed the Python3
+``print`` function, making it inaccessible at the ``pdb`` prompt.
+
+(Contributed by Connor Osborn in :issue:`18764`.)
+
+
poplib
------
diff --git a/Lib/pdb.py b/Lib/pdb.py
index 45fe477..1ec83da 100755
--- a/Lib/pdb.py
+++ b/Lib/pdb.py
@@ -1159,15 +1159,13 @@ class Pdb(bdb.Bdb, cmd.Cmd):
return _rstr('** raised %s **' % err)
def do_p(self, arg):
- """p(rint) expression
+ """p expression
Print the value of the expression.
"""
try:
self.message(repr(self._getval(arg)))
except:
pass
- # make "print" an alias of "p" since print isn't a Python statement anymore
- do_print = do_p
def do_pp(self, arg):
"""pp expression
@@ -1388,7 +1386,7 @@ class Pdb(bdb.Bdb, cmd.Cmd):
placed in the .pdbrc file):
# Print instance variables (usage "pi classInst")
- alias pi for k in %1.__dict__.keys(): print "%1.",k,"=",%1.__dict__[k]
+ alias pi for k in %1.__dict__.keys(): print("%1.",k,"=",%1.__dict__[k])
# Print instance variables in self
alias ps pi self
"""
@@ -1546,7 +1544,7 @@ 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', 'display', 'undisplay',
+ 'args', 'p', 'pp', 'whatis', 'source', 'display', 'undisplay',
'interact', 'alias', 'unalias', 'debug', 'quit',
]
diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py
index 0babaa0..e17f933 100644
--- a/Lib/test/test_pdb.py
+++ b/Lib/test/test_pdb.py
@@ -205,7 +205,8 @@ def test_pdb_breakpoint_commands():
... 'enable 1',
... 'clear 1',
... 'commands 2',
- ... 'print 42',
+ ... 'p "42"',
+ ... 'print("42", 7*6)', # Issue 18764 (not about breakpoints)
... 'end',
... 'continue', # will stop at breakpoint 2 (line 4)
... 'clear', # clear all!
@@ -252,11 +253,13 @@ def test_pdb_breakpoint_commands():
(Pdb) clear 1
Deleted breakpoint 1 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:3
(Pdb) commands 2
- (com) print 42
+ (com) p "42"
+ (com) print("42", 7*6)
(com) end
(Pdb) continue
1
- 42
+ '42'
+ 42 42
> <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>(4)test_function()
-> print(2)
(Pdb) clear
diff --git a/Misc/NEWS b/Misc/NEWS
index 3044d85..ab9cea7 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -34,6 +34,9 @@ Core and Builtins
Library
-------
+- Issue #18764: remove the 'print' alias for the PDB 'p' command so that it no
+ longer shadows the print function.
+
- Issue #19158: a rare race in BoundedSemaphore could allow .release() too
often.