GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — The `PyOS_*` hooks interact poorly with subinterpreters · Issue #104668 · python/cpython

The PyOS_* hooks interact poorly with subinterpreters #104668

New issue
Copy link
New issue
Copy link
Closed
Closed
The PyOS_* hooks interact poorly with subinterpreters#104668
Copy link
Assignees
brandtbucher
Labels
3.12only security fixesonly security fixes3.13only security fixesonly security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-C-APItopic-subinterpreterstopic-tkintertype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@brandtbucher
brandtbucher
opened on May 19, 2023
Issue body actions

PyOS_InputHook and PyOS_ReadlineFunctionPointer are globally-registered input hooks that have no way of recovering module-level state for the extensions that registered them. In practice, extensions like readline and tkinter get around this by using global state, which obviously isn't subinterpreter-friendly.

What's more, extensions without advertised subinterpreter support (like readline and tkinter) who register these hooks might find themselves called from within a subinterpreter (where their extension hasn't even been loaded). That's definitely a situation we want to avoid.

It seems like the best solution for 3.12 is to only call these hooks from the main interpreter, which makes the bad situation quite a bit better. If libraries really need better APIs that work per-interpreter and have ways to access module state, we can certainly add them later (but for now maybe we'll just cross our fingers and hope that nobody actually cares).

@ericsnowcurrently, how does this sound to you?

Linked PRs

  • GH-104668: Don't call PyOS_* hooks in subinterpreters #104674
  • [3.12] GH-104668: Don't call PyOS_* hooks in subinterpreters (GH-104674) #104760
Reacted by Oleg Iarygin, Erlend E. Aasland and Petr Viktorin

Activity

  1. brandtbucher
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    topic-tkinter
    topic-subinterpreters
    topic-C-API
    3.12only security fixesonly security fixes
    on May 19, 2023
  2. brandtbucher
    self-assigned this
    on May 19, 2023
  3. github-project-automation
    added this to Subinterpreterson May 19, 2023
  4. github-project-automation
    moved this to Todo in Subinterpreterson May 19, 2023
  5. arhadthedev
    added
    3.13only security fixesonly security fixes
    on May 22, 2023
  6. brandtbucher
    added a commit that references this issue on May 22, 2023

    GH-104668: Don't call PyOS_* hooks in subinterpreters (GH-104674)

    357bed0
  7. miss-islington
    added a commit that references this issue on May 22, 2023

    pythonGH-104668: Don't call PyOS_* hooks in subinterpreters (pythonGH…

    ef66708
  8. brandtbucher
    added a commit that references this issue on May 23, 2023

    [3.12] GH-104668: Don't call PyOS_* hooks in subinterpreters (GH-104760)

    905d419
  9. brandtbucher
    closed this as completedon May 23, 2023
  10. github-project-automation
    moved this from Todo to Done in Subinterpreterson May 23, 2023
  11. ericsnowcurrently commented on May 25, 2023

    @ericsnowcurrently
    ericsnowcurrently
    on May 25, 2023
    Member
    More actions

    Thanks for getting this sorted out, @brandtbucher.

    Reacted by Erlend E. Aasland
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @brandtbucher
    brandtbucher

Labels

3.12only security fixesonly security fixes3.13only security fixesonly security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-C-APItopic-subinterpreterstopic-tkintertype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Projects

  • Subinterpreters
    Status
    Done
    Show more project fields

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.