[issue35591] IDLE: Traceback on Find Selection

Terry J. Reedy report at bugs.python.org
Fri Dec 28 01:10:42 EST 2018


Terry J. Reedy <tjreedy at udel.edu> added the comment:

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.

----------
stage:  -> commit review
versions: +Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35591>
_______________________________________


More information about the Python-bugs-list mailing list