This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Python 3 pdb: shows internal code, breakpoints don't work
Type: behavior Stage:
Components: Interpreter Core Versions: Python 3.0
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: alex.gronholm, ericp, georg.brandl, pitrou
Priority: normal Keywords: patch

Created on 2009-05-27 19:15 by ericp, last changed 2022-04-11 14:56 by admin. This issue is now closed.

File name Uploaded Description Edit
pdb-fix.diff georg.brandl, 2009-08-09 21:59
Messages (7)
msg88431 - (view) Author: Eric Promislow (ericp) Date: 2009-05-27 19:15
I have a simple test file,, with this output:
$ cat
#!/usr/bin/env python

print("Line 1")
print("Line 2")
print("Line 3")
$ # Now try debugging it.
$ python3.0 -mpdb
> /home/ericp/opt/Python-3.0.1/lib/python3.0/>False
-> return self.raw.closed
(Pdb) b
Breakpoint 1 at /home/ericp/lab/Python-3.0.1/
(Pdb) r
> /home/ericp/opt/Python-3.0.1/lib/python3.0/>False
-> return self.buffer.closed
(Pdb) c
line 1
line 2
line 3
The program finished and will be restarted

Two main problems:

1. I shouldn't see the code for

2. The program doesn't stop at the breakpoint, because that 
stack frame is exposed to bdb as (file:"<string>", line:4),
not (file:"/home/.../", line:4).
msg88756 - (view) Author: Eric Promislow (ericp) Date: 2009-06-02 17:37
Similar problem with 3.1rc1:

C:\...>c:\Python31rc1\python.exe -m  pdb
> c:\python31rc1\lib\encodings\>b'Hello'
-> return codecs.charmap_encode(input,self.errors,encoding_map)[0]
(Pdb) b 2
*** Blank or comment
(Pdb) b
Breakpoint 1 at c:\...\

(Pdb) b
Num Type         Disp Enb   Where
1   breakpoint   keep yes   at c:\...\
(Pdb) c
The program finished and will be restarted
> c:\python31rc1\lib\encodings\>b'Hello'
-> return codecs.charmap_encode(input,self.errors,encoding_map)[0]
msg91433 - (view) Author: Alex Grönholm (alex.gronholm) * Date: 2009-08-09 21:25
Why has this not been resolved yet? Not having a working debugger is a
severe hindrance to the acceptance of Py3k.
msg91434 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-08-09 21:59
Attached patch confirmedly fixes this.  Will commit as soon as svn is
back up.
msg91468 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-08-11 06:11
Reading this patch, is it normal that the file is opened in text mode
without an encoding specified? What if the source file uses a different
encoding than the default system one?
msg91469 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-08-11 06:15
That's a good question :)

A quick test shows that exec() does honor coding cookies in code given
as a bytestring, so simply changing to open(..., "rb") should be fine.
msg91515 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-08-13 08:17
Fixed in r74366, and merged back to 3.1 branch in r74367.
Date User Action Args
2022-04-11 14:56:49adminsetgithub: 50376
2009-08-13 08:17:21georg.brandlsetstatus: open -> closed
resolution: fixed
messages: + msg91515
2009-08-11 06:15:41georg.brandlsetmessages: + msg91469
2009-08-11 06:11:06pitrousetnosy: + pitrou
messages: + msg91468
2009-08-09 21:59:49georg.brandlsetfiles: + pdb-fix.diff

nosy: + georg.brandl
messages: + msg91434

assignee: georg.brandl
keywords: + patch
2009-08-09 21:25:13alex.gronholmsetnosy: + alex.gronholm
messages: + msg91433
2009-06-02 17:37:30ericpsetmessages: + msg88756
2009-05-27 19:15:05ericpcreate