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

compile raises SyntaxError with undocumented lineno attribute None #88575

Closed
fweimer mannequin opened this issue Jun 13, 2021 · 6 comments
Closed

compile raises SyntaxError with undocumented lineno attribute None #88575

fweimer mannequin opened this issue Jun 13, 2021 · 6 comments
Labels
3.9 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@fweimer
Copy link
Mannequin

fweimer mannequin commented Jun 13, 2021

BPO 44409
Nosy @lysnikolaou, @pablogsal, @miss-islington
PRs
  • bpo-44409: Fix error location in tokenizer errors that happen during initialization #26712
  • [3.10] bpo-44409: Fix error location in tokenizer errors that happen during initialization (GH-26712) #26722
  • [3.9] bpo-44409: Fix error location in tokenizer errors that happen during initialization (GH-26712). #26723
  • 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 2021-06-14.17:27:22.615>
    created_at = <Date 2021-06-13.11:25:16.043>
    labels = ['interpreter-core', 'type-bug', '3.9']
    title = 'compile raises SyntaxError with undocumented lineno attribute None'
    updated_at = <Date 2021-06-14.17:27:22.614>
    user = 'https://bugs.python.org/fweimer'

    bugs.python.org fields:

    activity = <Date 2021-06-14.17:27:22.614>
    actor = 'pablogsal'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-06-14.17:27:22.615>
    closer = 'pablogsal'
    components = ['Parser']
    creation = <Date 2021-06-13.11:25:16.043>
    creator = 'fweimer'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 44409
    keywords = ['patch', '3.9regression', '3.10regression']
    message_count = 5.0
    messages = ['395740', '395763', '395778', '395811', '395814', '395815']
    nosy_count = 4.0
    nosy_names = ['fweimer', 'lys.nikolaou', 'pablogsal', 'miss-islington']
    pr_nums = ['26712', '26722', '26723']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue44409'
    versions = ['Python 3.9']

    @fweimer
    Copy link
    Mannequin Author

    fweimer mannequin commented Jun 13, 2021

    This example results in an undocumented value None for the lineno attribute:

    source = b"\xef\xbb\xbf#coding: utf8\nprint('\xe6\x88\x91')\n"
    
    try:
        compile(source, filename="example.py", mode="exec")
    except SyntaxError as e:
        print(str(e))
        print(type(e.lineno))
    

    Output:

    encoding problem: utf8 with BOM
    <class 'NoneType'>
    

    Seen with python3-3.9.5-2.fc33.x86_64.

    python3-3.8.10-1.fc32.x86_64 used a lineno value of 0 (type int).

    @fweimer fweimer mannequin added 3.9 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels Jun 13, 2021
    @pablogsal
    Copy link
    Member

    Well, in both cases this means that the line number is not available. I think None is a bit cleaner in this regard.

    @fweimer
    Copy link
    Mannequin Author

    fweimer mannequin commented Jun 14, 2021

    I suppose changing the documentation to mention None would be possible as well, but restoring the old behavior works for me too. Thanks.

    @pablogsal
    Copy link
    Member

    New changeset 507ed6f by Pablo Galindo in branch 'main':
    bpo-44409: Fix error location in tokenizer errors that happen during initialization (GH-26712)
    507ed6f

    @miss-islington
    Copy link
    Contributor

    New changeset 133cddf by Miss Islington (bot) in branch '3.10':
    bpo-44409: Fix error location in tokenizer errors that happen during initialization (GH-26712)
    133cddf

    @pablogsal
    Copy link
    Member

    New changeset 0d0a9ea by Pablo Galindo in branch '3.9':
    [3.9] bpo-44409: Fix error location in tokenizer errors that happen during initialization (GH-26712). (GH-26723)
    0d0a9ea

    @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.9 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

    2 participants