Issue 4890: handling empty text search pattern in tkinter (original) (raw)

Issue4890

Created on 2009-01-09 10:23 by mkiever, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
text_search_pattern.py mkiever,2009-01-09 10:23 demo program (see comment)
text_search_pattern.patch mkiever,2009-01-09 10:24 patch against trunk r68445
Messages (4)
msg79459 - (view) Author: Matthias Kievernagel (mkiever) * Date: 2009-01-09 10:23
Split this from issue 1581476 as suggested by Guilherme Polo (gpolo). >Matthias: your issue about the pattern should be placed in a >different >issue. Quote of my original report: (This is about the search function of the Text class in Tkinter. An IndexError is raised when pattern == '') ... >In addition I get an IndexError, if I delete the >last character of the search string. >Does Tk allow calling search with an empty pattern? >Tkinter could handle this (with a correct result) >with the following change in Tkinter.py / Text.search(): >if pattern[0] == '-': args.append('--') >-> >if pattern and pattern[0] == '-': args.append('--') A further remark from Guilherme Polo (gpolo): >For the suggestion about fixing the search method regarding the >pattern: >the fix is almost fine, but we need to disallow None as a pattern. I do not understand that remark. Is it to avoid the TclError? Or because the exception changes (IndexError -> TclError)? What do you want to do when pattern == None? Raise ValueError or IndexError (as before)? Appended slightly simplified demo program from issue 1581476 and a patch against trunk r68445. Cheers, Matthias Kievernagel mkiever/at/web/dot/de
msg79519 - (view) Author: Guilherme Polo (gpolo) * (Python committer) Date: 2009-01-09 22:21
I don't know what I was thinking when I said that, the check you are doing in the patch is fine. And just to answer your next question: it would raise ValueError. Also, it would be good to add the other missing search switches.
msg81463 - (view) Author: Guilherme Polo (gpolo) * (Python committer) Date: 2009-02-09 16:48
Fixed on r69461, r69462, r69463 and r69464, thanks. Will be adding tests for Tkinter.Text.search for trunk and py3k only.
msg81476 - (view) Author: Guilherme Polo (gpolo) * (Python committer) Date: 2009-02-09 19:22
I've added some tests for it on r69467 now.
History
Date User Action Args
2022-04-11 14:56:43 admin set github: 49140
2009-02-09 19:22:17 gpolo set messages: +
2009-02-09 16:48:09 gpolo set status: open -> closedresolution: fixedmessages: +
2009-02-09 16:40:16 gpolo set assignee: gpolo
2009-01-09 22:21:44 gpolo set nosy: + gpolomessages: + versions: + Python 3.0, Python 3.1, - Python 2.5, Python 2.4
2009-01-09 10:24:41 mkiever set files: + text_search_pattern.patchkeywords: + patch
2009-01-09 10:23:37 mkiever create