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

IDLE: Traceback on Find Selection #79772

Closed
csabella opened this issue Dec 26, 2018 · 6 comments
Closed

IDLE: Traceback on Find Selection #79772

csabella opened this issue Dec 26, 2018 · 6 comments
Assignees
Labels
3.7 (EOL) end of life 3.8 only security fixes topic-IDLE type-feature A feature request or enhancement

Comments

@csabella
Copy link
Contributor

BPO 35591
Nosy @terryjreedy, @csabella, @miss-islington
PRs
  • bpo-35591: IDLE Find Selection now works when selection not found #11339
  • [3.7] bpo-35591: IDLE Find Selection now works when selection not found (GH-11339) #11340
  • [3.7] bpo-35591: IDLE Find Selection now works when selection not found (GH-11339) #11342
  • 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 = 'https://github.com/terryjreedy'
    closed_at = <Date 2018-12-28.11:19:07.290>
    created_at = <Date 2018-12-26.18:50:50.703>
    labels = ['3.8', 'expert-IDLE', 'type-feature', '3.7']
    title = 'IDLE: Traceback on Find Selection'
    updated_at = <Date 2018-12-28.14:42:07.470>
    user = 'https://github.com/csabella'

    bugs.python.org fields:

    activity = <Date 2018-12-28.14:42:07.470>
    actor = 'cheryl.sabella'
    assignee = 'terry.reedy'
    closed = True
    closed_date = <Date 2018-12-28.11:19:07.290>
    closer = 'terry.reedy'
    components = ['IDLE']
    creation = <Date 2018-12-26.18:50:50.703>
    creator = 'cheryl.sabella'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 35591
    keywords = ['patch', 'patch', 'patch']
    message_count = 6.0
    messages = ['332559', '332643', '332645', '332647', '332652', '332662']
    nosy_count = 3.0
    nosy_names = ['terry.reedy', 'cheryl.sabella', 'miss-islington']
    pr_nums = ['11339', '11340', '11342']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue35591'
    versions = ['Python 3.7', 'Python 3.8']

    @csabella
    Copy link
    Contributor Author

    This probably isn't a traceback that's likely to happen, but I wanted to document it since I was able to recreate it.

    To recreate:
    In a new shell, do Select All, then Find Selection.

    Exception in Tkinter callback
    Traceback (most recent call last):
      File "N:\projects\cpython\lib\tkinter\__init__.py", line 1883, in __call__
        return self.func(*args)
      File "N:\projects\cpython\lib\idlelib\editor.py", line 644, in find_selection_event
        search.find_selection(self.text)
      File "N:\projects\cpython\lib\idlelib\search.py", line 25, in find_selection
        return _setup(text).find_selection(text)
      File "N:\projects\cpython\lib\idlelib\search.py", line 72, in find_selection
        return self.find_again(text)
      File "N:\projects\cpython\lib\idlelib\search.py", line 65, in find_again
        self.bell()
    AttributeError: 'SearchDialog' object has no attribute 'bell'

    @csabella csabella added the 3.8 only security fixes label Dec 26, 2018
    @csabella csabella added topic-IDLE type-feature A feature request or enhancement labels Dec 26, 2018
    @terryjreedy
    Copy link
    Member

    Thanks for reporting this. It is easy to trigger. And after a bit of analysis, easy to fix.

    self.bell is set as top.bell in searchbase.SearchDialogBase.create_widgets(). The latter is called by SDB.open(), which is called for Find, Find-again if there is no previously defined pattern, and Find-in-files. It is not called by Find-selection as it uses the selection as the pattern.

    The bell only sounds if the selection is not found anywhere else in the editor.
    if selfirst == first and sellast == last:
    self.bell()
    If the selection is found elsewhere, the copy is then tagged with the selection tag, so when the original is found, the condition is not true. I consider it a bug that the selection tag is used instead of the 'found' tag, but the above depends on it being moved.

    The purpose of creating and calling self.bell instead of top.bell is so bell can be mocked when testing, both to detect the call and suppress noise when testing. Binding self.bell to root.bell in __init__ instead of to top.bell in create_widgets should work fine.

    @terryjreedy terryjreedy added the 3.7 (EOL) end of life label Dec 28, 2018
    @terryjreedy
    Copy link
    Member

    I expect that people have run into this. But since callback exceptions do not crash IDLE, the only symptom when not running from a terminal is the lack of the 'bell' sound.

    @terryjreedy
    Copy link
    Member

    New changeset c465682 by Terry Jan Reedy in branch 'master':
    bpo-35591: IDLE Find Selection now works when selection not found (GH-11339)
    c465682

    @miss-islington
    Copy link
    Contributor

    New changeset 098bb24 by Miss Islington (bot) in branch '3.7':
    bpo-35591: IDLE Find Selection now works when selection not found (GH-11339)
    098bb24

    @csabella
    Copy link
    Contributor Author

    Thanks for looking at this one. :-)

    @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
    3.7 (EOL) end of life 3.8 only security fixes topic-IDLE type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants