summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/tkinter/__init__.py5
-rw-r--r--Misc/NEWS2
2 files changed, 5 insertions, 2 deletions
diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py
index a6397ea..af49170 100644
--- a/Lib/tkinter/__init__.py
+++ b/Lib/tkinter/__init__.py
@@ -3016,7 +3016,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')
@@ -3025,7 +3026,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)
diff --git a/Misc/NEWS b/Misc/NEWS
index 5a3b4ad..7cfddb2 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -160,6 +160,8 @@ Core and Builtins
Library
-------
+- Issue #4890: Handle empty text search pattern in Tkinter.Text.search.
+
- Issue #4512 (part 2): Promote ``ZipImporter._get_filename()`` to be a
public documented method ``ZipImporter.get_filename()``.