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.

Author gotgenes
Recipients
Date 2007-03-27.21:07:12
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
The Python debugger is unable to "jump" back to the first executable statement in a frame once that statement has been executed. For example:

chris@feathers:~/development/playground$ python -m pdb simple.py 
> /home/chris/development/playground/simple.py(3)?()
-> a = 1
(Pdb) next
> /home/chris/development/playground/simple.py(4)?()
-> b = 2
(Pdb) jump 3
> /home/chris/development/playground/simple.py(3)?()
-> a = 1
(Pdb) list
  1     #!/usr/bin/env python
  2  
  3     a = 1
  4  -> b = 2
  5  
  6     c = a + b
  7  
  8     print c
[EOF]
(Pdb) next
> /home/chris/development/playground/simple.py(6)?()
-> c = a + b

One can see that after supposedly "jump"ing to line 3 at the second command, when "list"ing the line, the debugger is actually at line 4. The "next" command further demonstrates this since it re-executes line 4 and moves to line 6.

This issue was raised on comp.lang.python. (For example, see
<http://groups.google.com/group/comp.lang.python/browse_thread/thread/7960201616873f41/e9623c08e3618051>
or if that link is munged, refer to
<http://tinyurl.com/324feu>

Duncan Booth offers the following:
[quote]
I verified (with a print statement in pdb) that assigning to self.curframe.f_lineno sets self.curframe.f_lineno and sel.curframe.f_lasti incorrectly

...

The problem looks to be in frameobject.c:

        addr = 0;
        line = f->f_code->co_firstlineno;
        new_lasti = -1;
        for (offset = 0; offset < lnotab_len; offset += 2) {
                addr += lnotab[offset];
                line += lnotab[offset+1];
                if (line >= new_lineno) {
                        new_lasti = addr;
                        new_lineno = line;
                        break;
                }
        }

The first bytes in lnotab are the length and line increment for line 3 (i.e. 6, 1). If line==f->f_code->co_firstlineno it should set new_lasti=0, new_lineno=line but the loop still executes once which increments new_lasti and new_lineno to the next line (6, 4).
[/quote]

And Rocky Bernstein offers the following:
[quote]
Best as I can tell, it looks like a bug in Python. pdb, pydb, rpdb2 all handle the "jump" command by changing the frame f_lineno value. When the corresponding code pointer has offset 0 (or equivalently and more simlply as you put it, is the first statement) this doesn't seem to work properly.
[/quote]
History
Date User Action Args
2007-08-23 14:52:46adminlinkissue1689458 messages
2007-08-23 14:52:46admincreate