This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: IDLE: Fix reporting RE error in searchengine
Type: behavior Stage: resolved
Components: IDLE Versions: Python 3.10, Python 3.9, Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: miss-islington, serhiy.storchaka, terry.reedy
Priority: normal Keywords: patch

Created on 2020-11-21 15:19 by serhiy.storchaka, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 23447 merged serhiy.storchaka, 2020-11-21 15:22
PR 23453 merged miss-islington, 2020-11-22 05:07
PR 23454 merged miss-islington, 2020-11-22 05:07
Messages (5)
msg381566 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-11-21 15:19
In Lib/idlelib/searchengine.py there is a code which decomposes re.error and reports error message, pattern, and position of error.

The problem is that that code does not match the structure of re.error. It takes args[0] as error message, and args[1] (if specified) as position in the pattern. But actually re.error always sets args[0] to formatted error message, and args has only one item. So some code in IDLE is dead.

Currently reported:

   Error: bad escape \z at position 1
   Pattern: a\z

Expected:

   Error: bad escape \z
   Pattern: a\z
   Offset: 1
msg381586 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-11-22 03:15
The confusion about error.args is this:

BaseException.args is documented as "The tuple of arguments given to the exception constructor."
https://docs.python.org/3/library/exceptions.html#base-classes
args[0] is usually and I would expect it to always be the formatted message, which is to say, the string normally printed at the end of tracebacks.
The signature of re.error is documented as "(msg, pattern=None, pos=None)"
https://docs.python.org/3/library/re.html#re.error
and this is what inspect.signature says (as reported in IDLE calltip).
So one might expect .args to be a 3-tuple.

With the value fetching fixed, the displayed message could be changed to something else (in another issue), such as
  Error: bad escape \z in pattern r'a\z' at offset 1

Thanks for the patch.
msg381588 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-11-22 05:06
New changeset 453bc1da2023d6cbe362637a2e0b06d0521f013c by Serhiy Storchaka in branch 'master':
bpo-42426: IDLE: Fix reporting offset of the RE error in searchengine (GH-23447)
https://github.com/python/cpython/commit/453bc1da2023d6cbe362637a2e0b06d0521f013c
msg381591 - (view) Author: miss-islington (miss-islington) Date: 2020-11-22 05:24
New changeset 28b40d7a349787817fe5f6ebfa753c29b96c8832 by Miss Islington (bot) in branch '3.8':
bpo-42426: IDLE: Fix reporting offset of the RE error in searchengine (GH-23447)
https://github.com/python/cpython/commit/28b40d7a349787817fe5f6ebfa753c29b96c8832
msg381594 - (view) Author: miss-islington (miss-islington) Date: 2020-11-22 05:30
New changeset dd20643b144d1c81989d235c3ec51f18fda618c2 by Miss Islington (bot) in branch '3.9':
bpo-42426: IDLE: Fix reporting offset of the RE error in searchengine (GH-23447)
https://github.com/python/cpython/commit/dd20643b144d1c81989d235c3ec51f18fda618c2
History
Date User Action Args
2022-04-11 14:59:38adminsetgithub: 86592
2020-11-22 05:56:33terry.reedysetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-11-22 05:30:57miss-islingtonsetmessages: + msg381594
2020-11-22 05:24:19miss-islingtonsetmessages: + msg381591
2020-11-22 05:07:13miss-islingtonsetpull_requests: + pull_request22345
2020-11-22 05:07:04miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request22344
2020-11-22 05:06:58terry.reedysetmessages: + msg381588
2020-11-22 03:15:57terry.reedysetmessages: + msg381586
2020-11-21 15:22:20serhiy.storchakasetkeywords: + patch
stage: patch review
pull_requests: + pull_request22339
2020-11-21 15:19:46serhiy.storchakasettype: behavior
2020-11-21 15:19:37serhiy.storchakacreate