Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

PYTHON_GIL=1 and -Xgil=1 should work in non-free-threading builds #123275

Closed
Labels
3.13bugs and security fixes3.14bugs and security fixestopic-free-threadingtype-bugAn unexpected behavior, bug, or error
@godlygeek

Description

@godlygeek

Bug report

Bug description:

In a non-free-threading build of Python 3.13, using environment variables or CLI arguments to ensure the GIL is used results in an error:

$PYTHON_GIL=1 python3.13Fatal Python error: config_read_gil: PYTHON_GIL / -X gil are not supported by this buildPython runtime state: preinitialized$python3.13 -Xgil=1Fatal Python error: config_read_gil: PYTHON_GIL / -X gil are not supported by this buildPython runtime state: preinitialized

This is user-hostile behavior that makes it more difficult to write tests and set up test environments. It makes sense thatPYTHON_GIL=0 or-Xgil=0 must fail for non-free-threading builds, but there's no reason why a user requesting that the GIL be enabled in a build where the GIL is always enabled should be an error rather than a no-op.

I bumped into this while working on the test suite forPyStack, where it has forced me into this nasty hack:

@pytest.fixture(autouse=True)defenable_gil_if_free_threading(python,monkeypatch):_,python_executable=pythonproc=subprocess.run([python_executable,"-Xgil=1","-cpass"],capture_output=True)free_threading=proc.returncode==0iffree_threading:monkeypatch.setenv("PYTHON_GIL","1")

instead of what I had originally wanted to do:

@pytest.fixture(autouse=True)defenable_gil_if_free_threading(monkeypatch):monkeypatch.setenv("PYTHON_GIL","1")

CPython versions tested on:

3.13

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13bugs and security fixes3.14bugs and security fixestopic-free-threadingtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp