[New-bugs-announce] [issue18764] The pdb print command prints repr instead of str in python3

R. David Murray report at bugs.python.org
Sat Aug 17 01:16:30 CEST 2013


New submission from R. David Murray:

In 2.7:

>>> import pdb
>>> from email import message_from_string as m
>>> x = m("To: me\nfrom: you\n\ntest\n")
>>> pdb.set_trace()
--Return--
> <stdin>(1)<module>()->None
(Pdb) print x
>From nobody Fri Aug 16 19:06:58 2013
To: me
from: you

test


In 3.4:

>>> import pdb
>>> from email import message_from_string as m
>>> x = m("To: me\nfrom: you\n\ntest\n")
>>> pdb.set_trace()
--Return--
> <stdin>(1)<module>()->None
(Pdb) print x
<email.message.Message object at 0xb707b92c>


Since the print command masks the print function, it is difficult (though
not impossible) to actually get the print representation of something:

(Pdb) print(str(x))
'To: me\nfrom: you\n\ntest\n'
(Pdb) not print(x)
To: me
from: you

test

True


Because print is a function rather than a statement in python3, it might be better to just drop the print command from pdb.  Someone working in Python3 is likely to type "print(...)" at the python3 pdb command line and expect it to work like the print function.

----------
components: Library (Lib)
keywords: easy
messages: 195439
nosy: r.david.murray
priority: normal
severity: normal
stage: needs patch
status: open
title: The pdb print command prints repr instead of str in python3
versions: Python 3.3, Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18764>
_______________________________________


More information about the New-bugs-announce mailing list