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.

classification
Title: Pdb breakpoints don't work on lines without bytecode
Type: behavior Stage: needs patch
Components: Library (Lib) Versions: Python 3.1, Python 3.2, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: asvetlov, georg.brandl, inducer, xdegaye
Priority: normal Keywords:

Created on 2009-06-22 14:09 by inducer, last changed 2022-04-11 14:56 by admin.

Messages (5)
msg89597 - (view) Author: Andreas Kloeckner (inducer) Date: 2009-06-22 14:09
Take this program:

8< -----------------------------------------------
print "START"

a = [
        1
        for i in range(10)]
8< -----------------------------------------------

as "a.py", run "python -m pdb a.py", say "b 3" to set a breakpoint on
line 3. Say "c" to start execution. Watch the program finish without
ever hitting the breakpoint.

The problem is that line 3 has no bytecode generated for it, so there's
nothing to break on. Pdb should provide feedback in this case. I'm the
author of PuDB, and I've written code to check for this condition Please
feel free to steal that code, here:

http://is.gd/19fvD
msg109903 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010-07-10 17:47
The OP has offered source code which fixes this issue, see msg89597.
msg171826 - (view) Author: Xavier de Gaye (xdegaye) * (Python triager) Date: 2012-10-02 19:19
Another example where pdb does not stop at breakpoints set at
global, else and finally statements:

$ nl -ba foo.py
     1  x = 1
     2  def main():
     3      global x
     4      try:
     5          if not x:
     6              x = 2
     7          else:
     8              x = 3
     9      finally:
    10          x = 4
    11
    12  if __name__ == "__main__":
    13      main()
    14      print(x)
    15
$ python3 -m pdb foo.py
> /path_to/foo.py(1)<module>()
-> x = 1
(Pdb) break 3
Breakpoint 1 at /path_to/foo.py:3
(Pdb) break 7
Breakpoint 2 at /path_to/foo.py:7
(Pdb) break 9
Breakpoint 3 at /path_to/foo.py:9
(Pdb) break 14
Breakpoint 4 at /path_to/foo.py:14
(Pdb) continue
> /path_to/foo.py(14)<module>()
-> print(x)
(Pdb)

==============
vim:sts=2:sw=2
msg172878 - (view) Author: Xavier de Gaye (xdegaye) * (Python triager) Date: 2012-10-14 12:16
This is fixed in the proposed patch named pdb_lnotab.patch attached to
issue 14913.
msg176278 - (view) Author: Xavier de Gaye (xdegaye) * (Python triager) Date: 2012-11-24 11:01
See also how this is fixed at
http://code.google.com/p/pdb-clone/source/detail?r=6b342324ebdc4558b83b9391e34478c1fa0752db
History
Date User Action Args
2022-04-11 14:56:50adminsetgithub: 50571
2012-11-24 11:01:15xdegayesetmessages: + msg176278
2012-10-14 12:16:41xdegayesetmessages: + msg172878
2012-10-07 12:28:10asvetlovsetnosy: + asvetlov
2012-10-02 19:19:08xdegayesetnosy: + xdegaye
messages: + msg171826
2010-10-12 16:33:27r.david.murraysetnosy: + georg.brandl, - BreamoreBoy
2010-07-10 17:47:09BreamoreBoysetversions: + Python 3.2, - Python 2.6, Python 2.5
nosy: + BreamoreBoy

messages: + msg109903

stage: needs patch
2009-06-22 14:09:13inducercreate