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

PyErr_SyntaxLocationEx() and PyErr_SyntaxLocationObject() always set the offset attribute to None #72698

Closed
serhiy-storchaka opened this issue Oct 22, 2016 · 7 comments
Labels
3.7 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@serhiy-storchaka
Copy link
Member

BPO 28512
Nosy @benjaminp, @berkerpeksag, @vadmium, @serhiy-storchaka
PRs
  • [Do Not Merge] Convert Misc/NEWS so that it is managed by towncrier #552
  • Files
  • PyErr_SyntaxLocationObject-offset.patch
  • 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 = None
    closed_at = <Date 2016-12-21.10:12:21.715>
    created_at = <Date 2016-10-22.21:50:07.312>
    labels = ['interpreter-core', 'type-bug', '3.7']
    title = 'PyErr_SyntaxLocationEx() and PyErr_SyntaxLocationObject() always set the offset attribute to None'
    updated_at = <Date 2017-03-31.16:36:35.683>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2017-03-31.16:36:35.683>
    actor = 'dstufft'
    assignee = 'none'
    closed = True
    closed_date = <Date 2016-12-21.10:12:21.715>
    closer = 'serhiy.storchaka'
    components = ['Interpreter Core']
    creation = <Date 2016-10-22.21:50:07.312>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = ['45574']
    hgrepos = []
    issue_num = 28512
    keywords = ['patch']
    message_count = 7.0
    messages = ['279224', '281305', '282913', '282917', '282918', '283055', '283080']
    nosy_count = 5.0
    nosy_names = ['benjamin.peterson', 'python-dev', 'berker.peksag', 'martin.panter', 'serhiy.storchaka']
    pr_nums = ['552']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue28512'
    versions = ['Python 3.5', 'Python 3.6', 'Python 3.7']

    @serhiy-storchaka
    Copy link
    Member Author

    The purpose of PyErr_SyntaxLocationEx() function (added in 00e4ce31d404) was setting the offset attribute of raised syntax error to specified value. But this never worked as expected. The offset attribute is set to integer value in Python/errors.c:1067, but then replaced with None in Python/errors.c:1083.

    @serhiy-storchaka serhiy-storchaka added 3.7 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels Oct 22, 2016
    @serhiy-storchaka
    Copy link
    Member Author

    Here is a patch that makes PyErr_SyntaxLocationObject() setting correct offset.

    @vadmium
    Copy link
    Member

    vadmium commented Dec 11, 2016

    Looks good apart from one quirky test case, see Reitveld

    @serhiy-storchaka
    Copy link
    Member Author

    Good catch Martin! Opened bpo-28936 for that quirky test.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Dec 11, 2016

    New changeset ea1c49ea8136 by Serhiy Storchaka in branch '3.5':
    Issue bpo-28512: Fixed setting the offset attribute of SyntaxError by
    https://hg.python.org/cpython/rev/ea1c49ea8136

    New changeset df59faf7fa59 by Serhiy Storchaka in branch '3.6':
    Issue bpo-28512: Fixed setting the offset attribute of SyntaxError by
    https://hg.python.org/cpython/rev/df59faf7fa59

    New changeset 72aaef2d144b by Serhiy Storchaka in branch 'default':
    Issue bpo-28512: Fixed setting the offset attribute of SyntaxError by
    https://hg.python.org/cpython/rev/72aaef2d144b

    @berkerpeksag
    Copy link
    Member

    Hi Serhiy, there are two commented-out lines in https://hg.python.org/cpython/rev/ea1c49ea8136#l3.10 (only in 3.5)

    + #with self.assertRaises(AssertionError):
    + #support.check_syntax_error(self, "x=1")

    @serhiy-storchaka
    Copy link
    Member Author

    Ah, it was a remnants of backporting to 3.5. Commented-out lines are used in 3.6. The line above these lines was used in 3.5. Test is passed with both variants. I commented out the 3.6 variant, but forgot to remove it (or remove old 3.5 variant and keep 3.6 variant). Do you think I should remove commented out lines, or left the code as is?

    @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.7 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants