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

Simplify setting line numbers in the compiler #84168

Closed
serhiy-storchaka opened this issue Mar 17, 2020 · 2 comments
Closed

Simplify setting line numbers in the compiler #84168

serhiy-storchaka opened this issue Mar 17, 2020 · 2 comments
Labels
3.9 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@serhiy-storchaka
Copy link
Member

BPO 39987
Nosy @brettcannon, @benjaminp, @serhiy-storchaka, @1st1, @pablogsal
PRs
  • bpo-39987: Simplify setting lineno in the compiler. #19037
  • 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 2020-03-17.16:08:21.656>
    created_at = <Date 2020-03-17.06:54:30.197>
    labels = ['interpreter-core', '3.9']
    title = 'Simplify setting line numbers in the compiler'
    updated_at = <Date 2020-03-17.16:08:21.655>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2020-03-17.16:08:21.655>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-03-17.16:08:21.656>
    closer = 'serhiy.storchaka'
    components = ['Interpreter Core']
    creation = <Date 2020-03-17.06:54:30.197>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 39987
    keywords = ['patch']
    message_count = 2.0
    messages = ['364388', '364441']
    nosy_count = 5.0
    nosy_names = ['brett.cannon', 'benjamin.peterson', 'serhiy.storchaka', 'yselivanov', 'pablogsal']
    pr_nums = ['19037']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue39987'
    versions = ['Python 3.9']

    @serhiy-storchaka
    Copy link
    Member Author

    Currently the compiler can set the line number to the instruction or keep it unset (zero). Then, when create linenotab it adds entries only for set line numbers. But in rare cases (docstring or the first instruction in the module, definition of a function with default arguments, maybe more) it may add multiple entries for the same lineno even if the bytecode offset is less than 255. Seems the only effect of this is a suboptimal linenotab.

    The proposed PR simplifies setting the line number in the compiler (it was the primary goal) and also fixes the above minor issue. The simplification is needed for several future changes in the compiler.

    @serhiy-storchaka serhiy-storchaka added 3.9 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Mar 17, 2020
    @serhiy-storchaka
    Copy link
    Member Author

    New changeset 61cb3d0 by Serhiy Storchaka in branch 'master':
    bpo-39987: Simplify setting lineno in the compiler. (GH-19037)
    61cb3d0

    @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)
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant