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: IDLE: Traceback on Find Selection
Type: enhancement Stage: resolved
Components: IDLE Versions: Python 3.8, Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: cheryl.sabella, miss-islington, terry.reedy
Priority: normal Keywords: patch, patch, patch

Created on 2018-12-26 18:50 by cheryl.sabella, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 11339 merged terry.reedy, 2018-12-28 06:22
PR 11340 closed miss-islington, 2018-12-28 07:41
PR 11342 merged miss-islington, 2018-12-28 10:14
Messages (6)
msg332559 - (view) Author: Cheryl Sabella (cheryl.sabella) * (Python committer) Date: 2018-12-26 18:50
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'
msg332643 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2018-12-28 06:10
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.
msg332645 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2018-12-28 06:29
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.
msg332647 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2018-12-28 07:41
New changeset c465682718f15cd3deb6b37db5fb607718ac64ed by Terry Jan Reedy in branch 'master':
bpo-35591: IDLE Find Selection now works when selection not found (GH-11339)
https://github.com/python/cpython/commit/c465682718f15cd3deb6b37db5fb607718ac64ed
msg332652 - (view) Author: miss-islington (miss-islington) Date: 2018-12-28 10:31
New changeset 098bb249e9cf315b9e3b7d4bdad039a093d049c4 by Miss Islington (bot) in branch '3.7':
bpo-35591: IDLE Find Selection now works when selection not found (GH-11339)
https://github.com/python/cpython/commit/098bb249e9cf315b9e3b7d4bdad039a093d049c4
msg332662 - (view) Author: Cheryl Sabella (cheryl.sabella) * (Python committer) Date: 2018-12-28 14:42
Thanks for looking at this one.  :-)
History
Date User Action Args
2022-04-11 14:59:09adminsetgithub: 79772
2018-12-28 14:42:07cheryl.sabellasetkeywords: patch, patch, patch

messages: + msg332662
2018-12-28 11:19:07terry.reedysetkeywords: patch, patch, patch
status: open -> closed
resolution: fixed
stage: patch review -> resolved
2018-12-28 10:31:36miss-islingtonsetnosy: + miss-islington
messages: + msg332652
2018-12-28 10:19:13terry.reedysetpull_requests: - pull_request10628
2018-12-28 10:19:01terry.reedysetpull_requests: - pull_request10629
2018-12-28 10:17:25terry.reedysetkeywords: patch, patch, patch
2018-12-28 10:14:15miss-islingtonsetpull_requests: + pull_request10629
2018-12-28 10:14:10miss-islingtonsetpull_requests: + pull_request10628
2018-12-28 10:14:04miss-islingtonsetpull_requests: + pull_request10627
2018-12-28 07:43:19terry.reedysetpull_requests: - pull_request10622
2018-12-28 07:43:08terry.reedysetpull_requests: - pull_request10623
2018-12-28 07:42:01miss-islingtonsetpull_requests: + pull_request10623
2018-12-28 07:41:55miss-islingtonsetpull_requests: + pull_request10622
2018-12-28 07:41:50miss-islingtonsetpull_requests: + pull_request10621
2018-12-28 07:41:43terry.reedysetmessages: + msg332647
2018-12-28 06:29:37terry.reedysetkeywords: patch, patch, patch

messages: + msg332645
2018-12-28 06:24:02terry.reedysetpull_requests: - pull_request10619
2018-12-28 06:23:52terry.reedysetpull_requests: - pull_request10620
2018-12-28 06:22:52terry.reedysetkeywords: + patch
stage: commit review -> patch review
pull_requests: + pull_request10620
2018-12-28 06:22:46terry.reedysetkeywords: + patch
stage: commit review -> commit review
pull_requests: + pull_request10619
2018-12-28 06:22:40terry.reedysetkeywords: + patch
stage: commit review -> commit review
pull_requests: + pull_request10618
2018-12-28 06:10:42terry.reedysetstage: commit review
messages: + msg332643
versions: + Python 3.7
2018-12-26 18:50:50cheryl.sabellacreate