]> granicus.if.org Git - python/commitdiff
Fixed issue #4890: Handle empty text search pattern in
authorGuilherme Polo <ggpolo@gmail.com>
Mon, 9 Feb 2009 16:41:09 +0000 (16:41 +0000)
committerGuilherme Polo <ggpolo@gmail.com>
Mon, 9 Feb 2009 16:41:09 +0000 (16:41 +0000)
Tkinter.Text.search

Lib/lib-tk/Tkinter.py
Misc/NEWS

index 8a9d8a4ff644f5772629452c8886caa79d83984f..fded2491d55fba8e5a733cdc0da485abf0b89879 100644 (file)
@@ -3032,7 +3032,8 @@ class Text(Widget):
            forwards=None, backwards=None, exact=None,
            regexp=None, nocase=None, count=None, elide=None):
         """Search PATTERN beginning from INDEX until STOPINDEX.
-        Return the index of the first character of a match or an empty string."""
+        Return the index of the first character of a match or an
+        empty string."""
         args = [self._w, 'search']
         if forwards: args.append('-forwards')
         if backwards: args.append('-backwards')
@@ -3041,7 +3042,7 @@ class Text(Widget):
         if nocase: args.append('-nocase')
         if elide: args.append('-elide')
         if count: args.append('-count'); args.append(count)
-        if pattern[0] == '-': args.append('--')
+        if pattern and pattern[0] == '-': args.append('--')
         args.append(pattern)
         args.append(index)
         if stopindex: args.append(stopindex)
index 9f56bb8c3ada3c293f080ab32c48cc54369dfe46..824b0d45a81c556bd15bc6c9c110bf56f6104ba2 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -152,6 +152,8 @@ Core and Builtins
 Library
 -------
 
+- Issue #4890: Handle empty text search pattern in Tkinter.Text.search.
+
 - Issue #5170: Fixed Unicode output bug in logging and added test case.
   This is a regression which did not occur in 2.5.