]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.11] [3.12] gh-83162: Rename re.error in idlelib (GH-101677) (GH-112987) (#113013)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 12 Dec 2023 16:21:07 +0000 (17:21 +0100)
committerGitHub <noreply@github.com>
Tue, 12 Dec 2023 16:21:07 +0000 (16:21 +0000)
Backport idlelib part of GH-101677 with simple rename.
(cherry picked from commit fd3b8947256309ba478a4e3ba8c0c81b1260b67f)

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Lib/idlelib/replace.py
Lib/idlelib/searchengine.py

index a29ca59142749157f447a82c88172f393af7f004..71e187f9279231303c8b213fc9f558ad9a6379e9 100644 (file)
@@ -4,6 +4,7 @@ Defines various replace related functions like replace, replace all,
 and replace+find.
 """
 import re
+re.PatternError = re.error  # New in 3.13.
 
 from tkinter import StringVar, TclError
 
@@ -120,7 +121,7 @@ class ReplaceDialog(SearchDialogBase):
         if self.engine.isre():
             try:
                 new = m.expand(repl)
-            except re.error:
+            except re.PatternError:
                 self.engine.report_error(repl, 'Invalid Replace Expression')
                 new = None
         else:
index 0684142f43644af5ad3a3a9f98d99111f51ed431..5119de05865b7a498489747e4bbebce680f5d562 100644 (file)
@@ -1,5 +1,6 @@
 '''Define SearchEngine for search dialogs.'''
 import re
+re.PatternError = re.error  # New in 3.13.
 
 from tkinter import StringVar, BooleanVar, TclError
 from tkinter import messagebox
@@ -84,7 +85,7 @@ class SearchEngine:
             flags = flags | re.IGNORECASE
         try:
             prog = re.compile(pat, flags)
-        except re.error as e:
+        except re.PatternError as e:
             self.report_error(pat, e.msg, e.pos)
             return None
         return prog