Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

serhiy-storchaka
Copy link
Member

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

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

@terryjreedy terryjreedy left a comment

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
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.setpat('+')
engine.revar.set(1)
Equal(engine.getprog(), None)
self.assertEqual(Mbox.showerror.message,
'Error: nothing to repeat at position 0\nPattern: +')
Copy link
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
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
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 bedevere-bot removed the needs backport to 3.9 only security fixes label Nov 22, 2020
@bedevere-bot
Copy link

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

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>
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