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: Breakpoints in debug lost if line is inserted; IDLE
Type: behavior Stage: resolved
Components: IDLE, Windows Versions: Python 3.4, Python 3.5, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Saimadhav.Heblikar, ltaylor934, python-dev, roger.serwy, terry.reedy
Priority: normal Keywords: patch

Created on 2012-02-24 01:35 by ltaylor934, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
debug-line-numbers.py ltaylor934, 2012-02-24 01:35 Trivial file with three lines, 1,2 and 3
remove-pyshell-comment.diff Saimadhav.Heblikar, 2014-08-11 15:30 review
Messages (9)
msg154104 - (view) Author: Larry A. Taylor (ltaylor934) Date: 2012-02-24 01:35
My environment is Windows XP, using IDLE and Python 2.7 distribution.

Open an IDLE Python shell. Open the file with three lines in it, 1,2 and 3.

In IDLE, Set Breakpoint on Line 2.

In Shell, set Debug.

In IDLE, select run. 

In the Debug window, click Go.

Run stops at line 2, displayed in Debug. Click Quit.

Edit the file, inserting a line 0, like: print "this is line 0". Save the file

Run again, Go in Debug. 

The breakpoint has disappeared and the debugger does not stop on line 2 (now the third line). It doesn't stop anywhere.

Delete line 0, and set breakpoint on line 2 again. At the end of the file, insert a line 4, such as: print "this is line 4".

Run again, Go in Debug.

The breakpoint is preserved, and the debugger stops at line 2.

This is inconsistent behavior. I expect that a breakpoint will not disappear, and that it will always point to the same line, moving down when the line moves down. The breakpoint should move up if the line it refers to moves up.
msg165815 - (view) Author: Roger Serwy (roger.serwy) * (Python committer) Date: 2012-07-18 22:16
The ColorDelegator is responsible for providing the coloring for the BREAK tag which is used to mark breakpoints. When recoloring, the BREAK tag may be removed (find self.tag_remove in recolorize_main). This is precisely why the breakpoints disappear.

On 2.7, you can use Control-/ to toggle the ColorDelegator. Doing so eliminates the behavior you describe. On 3.x, Control-/ is broken due to two ColorDelegators being loaded. See issue13495.

A possible solution would be to separate the BREAK tags from the color delegator since these tags ought to be part of the debugging code only.
msg225096 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-08-09 03:34
New changeset 76ca8569a04c by Terry Jan Reedy in branch '2.7':
Issue #14105: Stop removing breakpoints from Idle editors.
http://hg.python.org/cpython/rev/76ca8569a04c

New changeset d775fa9a9767 by Terry Jan Reedy in branch '3.4':
Issue #14105: Stop removing breakpoints from Idle editors.
http://hg.python.org/cpython/rev/d775fa9a9767
msg225097 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-08-09 03:40
I moved the BREAK tag configuration to PyShell.PyShellEditorWindow, which adds breakpoint support by subclassing EditorWindow. I wrapped the code in a function so we can also unconfig BREAK text colorizing. This might be desired when colored line numbers indicating breakpoints are added.
msg225104 - (view) Author: Saimadhav Heblikar (Saimadhav.Heblikar) * Date: 2014-08-09 14:13
Not sure if this consequence of the commit is intended behavior, but still placing it here. 

In any file, set a breakpoint on any line. Pressing <Enter> key anywhere after the first character, will create a new breakpoint in the next line. These lines will also get saved to the .idlerc/breakpoints.lst file.

This is mostly(99.9%) Tk behavior.
msg225108 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-08-09 19:45
On 8/9/2014 10:13 AM, Saimadhav Heblikar wrote:
>
> Saimadhav Heblikar added the comment:
>
> Not sure if this consequence of the commit is intended behavior,

It is.

> In any file, set a breakpoint on any line. Pressing <Enter> key
> anywhere after the first character, will create a new breakpoint in
> the next line.

Pressing any normal key within a tagged slice inserts the corresponding 
character within the slice.  If the character happens to be \n, then the 
*one* slice encompasses one more line than it did before.

A BREAK tag on line n encompasses one complete line, including terminal 
\n. In slice terms, n.0:(n+1).0. An xml version might look like the 
following.

<BREAK>This is something. This is something else
</BREAK>

Insert \n after 'some' and we have

<BREAK>This is some
thing. This is something else
</BREAK>

The tag now encompasses two complete lines (including, importantly, two 
\ns). This is standard slice insertion behavior, which tk provides us. 
There is no new slice created.

> These lines will also get saved to the .idlerc/breakpoints.lst file.

PyShellEditorWindow.store_file_breaks calls .update_breakpoints
This sends text.tag_ranges("BREAK") to .ranges_to_linenumbers.
This specifically accounts for possible insertions with this loop for 
each tag range.
             while lineno < end:  # lineno initially start line
                 lines.append(lineno)
                 lineno += 1

When I initially read the tag setting code, I wondered why include \n, 
why not the following?

<BREAK>This is something. This is something else</BREAK>

Possible insertion of \n is an answer.

The comment block for store_file_breaks addresses some of these issues, 
and needs revision after the patch.

I have been thinking that PyShellEditorWindow, later renamed 
EditorWindow*, should be BreakpointEditorWindow and moved to debugger.py.#

* not to be confused with EditorWindow.EditorWindow, which should really 
be called BaseEditorWindow.

# after applying either of your patches, at least locally.
msg225110 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-08-09 20:10
Forgot to mention: after inserting \n, the breakpoint tag can be cleared 
from either line independently. Tagging complete lines makes this easy. 
If a line is split into three and the middle line untagged, then the 
first and third are left separately tagged.
msg225195 - (view) Author: Saimadhav Heblikar (Saimadhav.Heblikar) * Date: 2014-08-11 15:30
While working on issue22083, I noticed a few redundant comments. This patch removes them.
msg229116 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-10-12 05:12
New changeset 71fe5e336d5b by Terry Jan Reedy in branch '2.7':
Issue #14105: Change comment to reflect fix.  Patch by Saimadhav Heblikar.
https://hg.python.org/cpython/rev/71fe5e336d5b

New changeset f33b4770a078 by Terry Jan Reedy in branch '3.4':
Issue #14105: Change comment to reflect fix.  Patch by Saimadhav Heblikar.
https://hg.python.org/cpython/rev/f33b4770a078

New changeset 558d7fb48d74 by Terry Jan Reedy in branch 'default':
Issue #14105: Merge with 3.4
https://hg.python.org/cpython/rev/558d7fb48d74
History
Date User Action Args
2022-04-11 14:57:27adminsetgithub: 58313
2014-10-12 05:12:07python-devsetmessages: + msg229116
2014-08-11 15:30:04Saimadhav.Heblikarsetfiles: + remove-pyshell-comment.diff
keywords: + patch
messages: + msg225195
2014-08-09 20:10:55terry.reedysetmessages: + msg225110
2014-08-09 19:45:02terry.reedysetmessages: + msg225108
2014-08-09 14:13:18Saimadhav.Heblikarsetnosy: + Saimadhav.Heblikar
messages: + msg225104
2014-08-09 03:40:54terry.reedysetstatus: open -> closed
resolution: fixed
messages: + msg225097

stage: resolved
2014-08-09 03:34:07python-devsetnosy: + python-dev
messages: + msg225096
2014-07-30 21:49:46BreamoreBoysetversions: + Python 3.5, - Python 3.3
2013-06-15 18:51:49terry.reedysetversions: + Python 3.4, - Python 3.2
2012-07-18 22:16:29roger.serwysetnosy: + roger.serwy

messages: + msg165815
versions: + Python 3.2, Python 3.3
2012-02-25 01:18:53terry.reedysetnosy: + terry.reedy
2012-02-24 01:35:26ltaylor934create