Skip to content

bpo-42426: IDLE: Fix reporting offset of the RE error in searchengine#23447

Merged
terryjreedy merged 3 commits into
python:masterfrom
serhiy-storchaka:idle-searchengine-re-error
Nov 22, 2020
Merged

bpo-42426: IDLE: Fix reporting offset of the RE error in searchengine#23447
terryjreedy merged 3 commits into
python:masterfrom
serhiy-storchaka:idle-searchengine-re-error

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Nov 21, 2020

Copy link
Copy Markdown
Member

@serhiy-storchaka
serhiy-storchaka force-pushed the idle-searchengine-re-error branch from 9360904 to 8a96705 Compare November 21, 2020 15:58

@terryjreedy terryjreedy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first two comments, on the buggy old code, are for me and any other future readers.
I will merge when the retest passes.

except re.error as what:
args = what.args
msg = args[0]
col = args[1] if len(args) >= 2 else -1

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was my 'fix' for the original 2020 code that had msg, col = what. Even is args was a 3-tuple as I expected (see issue), that should have been args[2]. Since args is a 1-tuple, this always resulted in -1.

engine.revar.set(1)
Equal(engine.getprog(), None)
self.assertEqual(Mbox.showerror.message,
'Error: nothing to repeat at position 0\nPattern: +')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I reviewed this file, written by GSOC student, I missed that this test passes because the buggy expected matches the buggy result of buggy code.

msg = args[0]
col = args[1] if len(args) >= 2 else -1
self.report_error(pat, msg, col)
except re.error as e:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the change to 'e' and simplification of code.

@terryjreedy
terryjreedy merged commit 453bc1d into python:master Nov 22, 2020
@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @serhiy-storchaka for the PR, and @terryjreedy for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8, 3.9.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Nov 22, 2020
…pythonGH-23447)

(cherry picked from commit 453bc1d)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@bedevere-bot

Copy link
Copy Markdown

GH-23453 is a backport of this pull request to the 3.9 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Nov 22, 2020
…pythonGH-23447)

(cherry picked from commit 453bc1d)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@bedevere-bot

Copy link
Copy Markdown

GH-23454 is a backport of this pull request to the 3.8 branch.

miss-islington added a commit that referenced this pull request Nov 22, 2020
…GH-23447)

(cherry picked from commit 453bc1d)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
miss-islington added a commit that referenced this pull request Nov 22, 2020
…GH-23447)

(cherry picked from commit 453bc1d)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@serhiy-storchaka
serhiy-storchaka deleted the idle-searchengine-re-error branch July 1, 2026 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type-bug An unexpected behavior, bug, or error

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants