Skip to content
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

IDLE: Fix reporting RE error in searchengine #86592

Closed
serhiy-storchaka opened this issue Nov 21, 2020 · 5 comments
Closed

IDLE: Fix reporting RE error in searchengine #86592

serhiy-storchaka opened this issue Nov 21, 2020 · 5 comments
Assignees
Labels
3.8 only security fixes 3.9 only security fixes 3.10 only security fixes topic-IDLE type-bug An unexpected behavior, bug, or error

Comments

@serhiy-storchaka
Copy link
Member

BPO 42426
Nosy @terryjreedy, @serhiy-storchaka, @miss-islington
PRs
  • bpo-42426: IDLE: Fix reporting offset of the RE error in searchengine #23447
  • [3.9] bpo-42426: IDLE: Fix reporting offset of the RE error in searchengine (GH-23447) #23453
  • [3.8] bpo-42426: IDLE: Fix reporting offset of the RE error in searchengine (GH-23447) #23454
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/terryjreedy'
    closed_at = <Date 2020-11-22.05:56:33.933>
    created_at = <Date 2020-11-21.15:19:37.261>
    labels = ['expert-IDLE', 'type-bug', '3.8', '3.9', '3.10']
    title = 'IDLE: Fix reporting RE error in searchengine'
    updated_at = <Date 2020-11-22.05:56:33.932>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2020-11-22.05:56:33.932>
    actor = 'terry.reedy'
    assignee = 'terry.reedy'
    closed = True
    closed_date = <Date 2020-11-22.05:56:33.933>
    closer = 'terry.reedy'
    components = ['IDLE']
    creation = <Date 2020-11-21.15:19:37.261>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 42426
    keywords = ['patch']
    message_count = 5.0
    messages = ['381566', '381586', '381588', '381591', '381594']
    nosy_count = 3.0
    nosy_names = ['terry.reedy', 'serhiy.storchaka', 'miss-islington']
    pr_nums = ['23447', '23453', '23454']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue42426'
    versions = ['Python 3.8', 'Python 3.9', 'Python 3.10']

    @serhiy-storchaka
    Copy link
    Member Author

    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

    @serhiy-storchaka serhiy-storchaka added 3.8 only security fixes 3.9 only security fixes 3.10 only security fixes labels Nov 21, 2020
    @serhiy-storchaka serhiy-storchaka added topic-IDLE type-bug An unexpected behavior, bug, or error labels Nov 21, 2020
    @terryjreedy
    Copy link
    Member

    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.

    @terryjreedy
    Copy link
    Member

    New changeset 453bc1d by Serhiy Storchaka in branch 'master':
    bpo-42426: IDLE: Fix reporting offset of the RE error in searchengine (GH-23447)
    453bc1d

    @miss-islington
    Copy link
    Contributor

    New changeset 28b40d7 by Miss Islington (bot) in branch '3.8':
    bpo-42426: IDLE: Fix reporting offset of the RE error in searchengine (GH-23447)
    28b40d7

    @miss-islington
    Copy link
    Contributor

    New changeset dd20643 by Miss Islington (bot) in branch '3.9':
    bpo-42426: IDLE: Fix reporting offset of the RE error in searchengine (GH-23447)
    dd20643

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 only security fixes 3.9 only security fixes 3.10 only security fixes topic-IDLE type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants