[New-bugs-announce] [issue4890] handling empty text search pattern in tkinter

Matthias Kievernagel report at bugs.python.org
Fri Jan 9 11:23:49 CET 2009


New submission from Matthias Kievernagel <mkiever at web.de>:

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

----------
components: Tkinter
files: text_search_pattern.py
messages: 79459
nosy: mkiever
severity: normal
status: open
title: handling empty text search pattern in tkinter
versions: Python 2.4, Python 2.5, Python 2.6, Python 2.7
Added file: http://bugs.python.org/file12660/text_search_pattern.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4890>
_______________________________________


More information about the New-bugs-announce mailing list