Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breakpoints in debug lost if line is inserted; IDLE #58313

Closed
ltaylor934 mannequin opened this issue Feb 24, 2012 · 9 comments
Closed

Breakpoints in debug lost if line is inserted; IDLE #58313

ltaylor934 mannequin opened this issue Feb 24, 2012 · 9 comments
Labels
OS-windows topic-IDLE type-bug An unexpected behavior, bug, or error

Comments

@ltaylor934
Copy link
Mannequin

ltaylor934 mannequin commented Feb 24, 2012

BPO 14105
Nosy @terryjreedy, @serwy
Files
  • debug-line-numbers.py: Trivial file with three lines, 1,2 and 3
  • remove-pyshell-comment.diff
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2014-08-09.03:40:54.898>
    created_at = <Date 2012-02-24.01:35:26.322>
    labels = ['expert-IDLE', 'type-bug', 'OS-windows']
    title = 'Breakpoints in debug lost if line is inserted; IDLE'
    updated_at = <Date 2014-10-12.05:12:07.941>
    user = 'https://bugs.python.org/ltaylor934'

    bugs.python.org fields:

    activity = <Date 2014-10-12.05:12:07.941>
    actor = 'python-dev'
    assignee = 'none'
    closed = True
    closed_date = <Date 2014-08-09.03:40:54.898>
    closer = 'terry.reedy'
    components = ['IDLE', 'Windows']
    creation = <Date 2012-02-24.01:35:26.322>
    creator = 'ltaylor934'
    dependencies = []
    files = ['24621', '36349']
    hgrepos = []
    issue_num = 14105
    keywords = ['patch']
    message_count = 9.0
    messages = ['154104', '165815', '225096', '225097', '225104', '225108', '225110', '225195', '229116']
    nosy_count = 5.0
    nosy_names = ['terry.reedy', 'roger.serwy', 'python-dev', 'ltaylor934', 'Saimadhav.Heblikar']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue14105'
    versions = ['Python 2.7', 'Python 3.4', 'Python 3.5']

    @ltaylor934
    Copy link
    Mannequin Author

    ltaylor934 mannequin commented Feb 24, 2012

    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.

    @ltaylor934 ltaylor934 mannequin added topic-IDLE OS-windows type-bug An unexpected behavior, bug, or error labels Feb 24, 2012
    @serwy
    Copy link
    Mannequin

    serwy mannequin commented Jul 18, 2012

    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 bpo-13495.

    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.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Aug 9, 2014

    New changeset 76ca8569a04c by Terry Jan Reedy in branch '2.7':
    Issue bpo-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 bpo-14105: Stop removing breakpoints from Idle editors.
    http://hg.python.org/cpython/rev/d775fa9a9767

    @terryjreedy
    Copy link
    Member

    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.

    @SaimadhavHeblikar
    Copy link
    Mannequin

    SaimadhavHeblikar mannequin commented Aug 9, 2014

    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.

    @terryjreedy
    Copy link
    Member

    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.

    @terryjreedy
    Copy link
    Member

    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.

    @SaimadhavHeblikar
    Copy link
    Mannequin

    SaimadhavHeblikar mannequin commented Aug 11, 2014

    While working on bpo-22083, I noticed a few redundant comments. This patch removes them.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Oct 12, 2014

    New changeset 71fe5e336d5b by Terry Jan Reedy in branch '2.7':
    Issue bpo-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 bpo-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 bpo-14105: Merge with 3.4
    https://hg.python.org/cpython/rev/558d7fb48d74

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    OS-windows topic-IDLE type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant