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 — Make `_struct` module thread-safe in `--disable-gil` builds · Issue #112062 · python/cpython

Make _struct module thread-safe in --disable-gil builds #112062

New issue
Copy link
New issue
Copy link
Closed
#112094
Closed
Make _struct module thread-safe in --disable-gil builds#112062
#112094
Copy link
Assignees
chgnrdv
Labels
3.13only security fixesonly security fixesextension-modulesC modules in the Modules dirC modules in the Modules dirtopic-free-threadingtype-featureA feature request or enhancementA feature request or enhancement

Description

@colesbury
colesbury
opened on Nov 14, 2023
Issue body actions

Feature or enhancement

The _struct module has a few small issues:

  • The use of PyDict_GetItemWithError returns a borrowed reference (should use PyDict_GetItemRef)
  • The state->cache is lazily created; we should instead create it during _structmodule_exec
  • We want state->cache to be an immutable reference to a mutable dict. (The dict will be thread-safe.) Use PyDict_Clear to empty the dict instead of clearing the reference.

See the commit from the nogil-3.12 fork for context: colesbury/nogil-3.12@ada9b73feb. Note that in CPython the relevant function is PyDict_GetItemRef not PyDict_FetchItemWithError.

Linked PRs

  • gh-112062: Make _struct module thread-safe in --disable-gil builds #112094

Activity

  1. colesbury
    added
    type-featureA feature request or enhancementA feature request or enhancement
    3.13only security fixesonly security fixes
    topic-free-threading
    on Nov 14, 2023
  2. AlexWaygood
    added
    extension-modulesC modules in the Modules dirC modules in the Modules dir
    on Nov 14, 2023
  3. chgnrdv commented on Nov 14, 2023

    @chgnrdv
    chgnrdv
    on Nov 14, 2023
    Contributor
    More actions

    I'll submit a PR :)

  4. colesbury
    assigned
    chgnrdv
    on Nov 15, 2023
  5. kumaraditya303
    closed this as completedin #112094on Nov 15, 2023
  6. kumaraditya303
    added a commit that references this issue on Nov 15, 2023

    gh-112062: Make `_struct` module thread-safe in `--disable-gil` builds (

    4744f59
  7. aisk
    added a commit that references this issue on Feb 11, 2024

    pythongh-112062: Make `_struct` module thread-safe in `--disable-gil`…

    06ceee9
  8. Glyphack
    added a commit that references this issue on Sep 2, 2024

    pythongh-112062: Make `_struct` module thread-safe in `--disable-gil`…

    630ac12
  9. serhiy-storchaka
    added this to Struct, memoryview and array issues 🏗️on Jul 13, 2026
  10. github-project-automation
    moved this to Done in Struct, memoryview and array issues 🏗️on Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @chgnrdv
    chgnrdv

Labels

3.13only security fixesonly security fixesextension-modulesC modules in the Modules dirC modules in the Modules dirtopic-free-threadingtype-featureA feature request or enhancementA feature request or enhancement

Projects

  • Struct, memoryview and array issues 🏗️
    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.