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 — Forcing enabling the GIL doesn't seem to work with PEP 793 initialization · Issue #141780 · python/cpython

Forcing enabling the GIL doesn't seem to work with PEP 793 initialization #141780

New issue
Copy link
New issue
Copy link
Closed
Closed
Forcing enabling the GIL doesn't seem to work with PEP 793 initialization#141780
Copy link
Assignees
encukou
Labels
3.15bugs and security fixesbugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-free-threadingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@da-woods
da-woods
opened on Nov 20, 2025
Issue body actions

Bug report

Bug description:

#include <Python.h>

static int
examplemodule_exec(PyObject *module) {
    // Yes I know there's no error checking...
    PyObject *gil_enabled = PySys_GetObject("_is_gil_enabled");
    PyObject *result = PyObject_CallNoArgs(gil_enabled);
    printf("gil enabled: ");
    PyObject_Print(result, stdout, 0);
    printf("\n");
    Py_DECREF(result);
    return 0;
}

static PyModuleDef_Slot examplemodule_slots[] = {
    {Py_mod_name, "examplemodule"},
    {Py_mod_gil, Py_MOD_GIL_USED},
    {Py_mod_exec, (void*)examplemodule_exec},
    {0}
};

PyMODEXPORT_FUNC
PyModExport_examplemodule(void)
{
    return examplemodule_slots;
}

I believe that the code above should print "gil enabled: True". However when I run it on Python 3.15.0a2 freethreading it prints "gil enabled: False".

I don't believe this is an issue in the old style PyInit_ initialization.

CPython versions tested on:

3.15

Operating systems tested on:

Linux

Linked PRs

  • gh-141780: Make PyModule_FromSlotsAndSpec enable GIL if needed  #141785

Activity

  1. da-woods
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Nov 20, 2025
  2. da-woods
    changed the title [-]Disabling the GIL doesn't seem to work with PEP 793 initialization[/-] [+]Forcing enabling the GIL doesn't seem to work with PEP 793 initialization[/+] on Nov 20, 2025
  3. da-woods commented on Nov 20, 2025

    @da-woods
    da-woods
    on Nov 20, 2025
    ContributorAuthor
    More actions

    @encukou

    Reacted by Petr Viktorin
  4. encukou
    self-assigned this
    on Nov 20, 2025
  5. encukou
    added a commit that references this issue on Nov 20, 2025

    pythongh-141780: Make PyModule_FromSlotsAndSpec enable GIL if needed

    13faf0f
  6. encukou commented on Nov 20, 2025

    @encukou
    encukou
    on Nov 20, 2025
    Member
    More actions

    Thanks for the catch!

  7. StanFromIreland
    added
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    on Nov 20, 2025
  8. picnixz
    added
    3.15bugs and security fixesbugs and security fixes
    topic-free-threading
    on Nov 22, 2025
  9. encukou
    added a commit that references this issue on Nov 24, 2025

    gh-141780: Make PyModule_FromSlotsAndSpec enable GIL if needed (GH-1…

    bf66bce
  10. encukou
    closed this as completedon Nov 24, 2025
  11. da-woods commented on Nov 24, 2025

    @da-woods
    da-woods
    on Nov 24, 2025
    ContributorAuthor
    More actions

    Thanks

  12. StanFromIreland
    added a commit that references this issue on Dec 6, 2025

    pythongh-141780: Make PyModule_FromSlotsAndSpec enable GIL if needed (…

    f614d18
  13. ashm-dev
    added a commit that references this issue on Dec 8, 2025

    pythongh-141780: Make PyModule_FromSlotsAndSpec enable GIL if needed (…

    1fdf8af
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @encukou
    encukou

Labels

3.15bugs and security fixesbugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-free-threadingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402520 — 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.