mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
bpo-42426: IDLE: Fix reporting offset of the RE error in searchengine (GH-23447)
This commit is contained in:
parent
442746af64
commit
453bc1da20
4 changed files with 11 additions and 9 deletions
|
@ -84,20 +84,17 @@ class SearchEngine:
|
|||
flags = flags | re.IGNORECASE
|
||||
try:
|
||||
prog = re.compile(pat, flags)
|
||||
except re.error as what:
|
||||
args = what.args
|
||||
msg = args[0]
|
||||
col = args[1] if len(args) >= 2 else -1
|
||||
self.report_error(pat, msg, col)
|
||||
except re.error as e:
|
||||
self.report_error(pat, e.msg, e.pos)
|
||||
return None
|
||||
return prog
|
||||
|
||||
def report_error(self, pat, msg, col=-1):
|
||||
def report_error(self, pat, msg, col=None):
|
||||
# Derived class could override this with something fancier
|
||||
msg = "Error: " + str(msg)
|
||||
if pat:
|
||||
msg = msg + "\nPattern: " + str(pat)
|
||||
if col >= 0:
|
||||
if col is not None:
|
||||
msg = msg + "\nOffset: " + str(col)
|
||||
tkMessageBox.showerror("Regular expression error",
|
||||
msg, master=self.root)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue