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

Statically Initialize PyArg_Parser in clinic.py #90928

Closed
ericsnowcurrently opened this issue Feb 16, 2022 · 2 comments
Closed

Statically Initialize PyArg_Parser in clinic.py #90928

ericsnowcurrently opened this issue Feb 16, 2022 · 2 comments
Assignees
Labels
3.11 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@ericsnowcurrently
Copy link
Member

BPO 46772
Nosy @ericsnowcurrently
Dependencies
  • bpo-46753: Statically allocate and initialize the empty tuple.
  • bpo-46773: Add a Private API for Looking Up Global Objects
  • 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/ericsnowcurrently'
    closed_at = None
    created_at = <Date 2022-02-16.18:32:25.886>
    labels = ['interpreter-core', '3.11']
    title = 'Statically Initialize PyArg_Parser in clinic.py'
    updated_at = <Date 2022-02-16.18:36:54.761>
    user = 'https://github.com/ericsnowcurrently'

    bugs.python.org fields:

    activity = <Date 2022-02-16.18:36:54.761>
    actor = 'eric.snow'
    assignee = 'eric.snow'
    closed = False
    closed_date = None
    closer = None
    components = ['Interpreter Core']
    creation = <Date 2022-02-16.18:32:25.886>
    creator = 'eric.snow'
    dependencies = ['46753', '46773']
    files = []
    hgrepos = []
    issue_num = 46772
    keywords = []
    message_count = 1.0
    messages = ['413351']
    nosy_count = 1.0
    nosy_names = ['eric.snow']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = 'needs patch'
    status = 'open'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue46772'
    versions = ['Python 3.11']

    @ericsnowcurrently
    Copy link
    Member Author

    The code generated by clinic.py is already partially statically initialized. Currently we init the other fields in Python/getargs.c:parser_init(), which runs the first time we try to use each parser. AFAICS, that remaining init that could be done statically using the data we have available in clinic.py during code generation.

    My primary interest is in static init of PyArg_Parser.kwtuple, which is a tuple containing only strings.

    @ericsnowcurrently ericsnowcurrently added the 3.11 only security fixes label Feb 16, 2022
    @ericsnowcurrently ericsnowcurrently self-assigned this Feb 16, 2022
    @ericsnowcurrently ericsnowcurrently added interpreter-core (Objects, Python, Grammar, and Parser dirs) 3.11 only security fixes labels Feb 16, 2022
    @ericsnowcurrently ericsnowcurrently self-assigned this Feb 16, 2022
    @ericsnowcurrently ericsnowcurrently added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Feb 16, 2022
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    ericsnowcurrently added a commit that referenced this issue Aug 11, 2022
    …d Code (gh-95860)
    
    We only statically initialize for core code and builtin modules.  Extension modules still create
    the tuple at runtime.  We'll solve that part of interpreter isolation separately.
    
    This change includes generated code. The non-generated changes are in:
    
    * Tools/clinic/clinic.py
    * Python/getargs.c
    * Include/cpython/modsupport.h
    * Makefile.pre.in (re-generate global strings after running clinic)
    * very minor tweaks to Modules/_codecsmodule.c and Python/Python-tokenize.c
    
    All other changes are generated code (clinic, global strings).
    @ericsnowcurrently
    Copy link
    Member Author

    gh-95909 follows up on interpreter isolation for PyArg_Parser.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.11 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs)
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant