Skip to content

gh-154757: Remove deprecated PyEval_InitThreads() function - #158037

Merged
vstinner merged 1 commit into
python:mainfrom
vstinner:remove_init_threads
Sep 24, 2026
Merged

vstinner merged 1 commit into
python:mainfrom
vstinner:remove_init_threads

Conversation

@vstinner

@vstinner vstinner commented Sep 23, 2026 •

Copy link
Copy Markdown
Member
@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #34727428 | 📁 Comparing a885673 against main (6893326)

  🔍 Preview build  

5 files changed · ± 5 modified

± Modified

@vstinner

Copy link
Copy Markdown
Member Author

I already removed this function once in 2023, in Python 3.13 alpha1! PR gh-105183 of issue gh-105182 (commit ec0082c). I restored this function in Python 3.13 beta1 because it affected 16 projects in Fedora: PR gh-117931 (commit 75eed5b). In the meanwhile, some projects have been updated to no longer call PyEval_InitThreads() on Python 3.7 and newer.

@vstinner
vstinner merged commit 8293654 into python:main Sep 24, 2026
59 checks passed
@vstinner
vstinner deleted the remove_init_threads branch September 24, 2026 08:48
@encukou

encukou commented Nov 23, 2026

Copy link
Copy Markdown
Member

This goes directly against PEP 387:

If the expected maintenance overhead and security risk of the deprecated behavior is small (e.g. an old function is reimplemented in terms of a new, more general one), it can stay indefinitely (or until the situation changes).

See discussion the removal spawned: https://discuss.python.org/t/110257

@vstinner

Copy link
Copy Markdown
Member Author

Since the removal of this function is being discussed, I ran a code search to estimate how many C extensions are affected.

I searched for PyEval_InitThreads in PyPI top 15,000 projects (at 2026-09-17).

I found 11 projects affected by the removal:

  • debugpy (1.8.22)
  • gilknocker (0.4.2)
  • mecab_ko (1.0.2)
  • mecab_python3 (1.0.12)
  • modulegraph2 (2.3)
  • ptvsd (4.3.2)
  • pygdal (3.6.4.11)
  • python_crfsuite (0.9.12)
  • pythonnet (3.1.0)
  • ur_rtde (1.6.5)
  • wxpython (4.3.1)

Some of these projects have to update SWIG or pybind11 to get the fix.


On the other side, 43 projects mention PyEval_InitThreads but are not affected by this removal:

  • Use #if such as #if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 9
  • Only mention the function in comments or Changelog
  • Or mention in a pyo3-ffi binding which is not used

The 43 projects:

  • PyAudio (0.2.14)
  • PyQt5 (5.15.11)
  • RPi.GPIO (0.7.1)
  • awscrt (0.36.4)
  • casadi (3.8.1)
  • cassandra_driver (3.30.1)
  • clingo (5.8.2)
  • confluent_kafka (2.15.1)
  • coreforecast (0.0.18)
  • cvxpy (1.9.2)
  • cvxpy_base (1.9.2)
  • cython (3.3.0)
  • dlib (20.0.1)
  • gdal (3.13.3)
  • ihm (2.11)
  • instanttensor (0.2.0)
  • libpff-python (20231205)
  • madoka (0.7.2.1)
  • minorminer (0.2.22)
  • ncnn (1.0.20260526)
  • ntgcalls (2.2.5)
  • opencc (1.4.2)
  • orjson (3.12.0)
  • pemja (0.6.2)
  • plyvel (1.5.1)
  • praat_parselmouth (0.4.7)
  • pycurl (7.48.0)
  • pydevd (3.5.0)
  • pydevd_pycharm (263.4732.31)
  • pygame (2.6.1)
  • pygments (2.21.0)
  • pygobject (3.58.0)
  • pylibyear (0.5.0)
  • pyobjc_core (12.2.2)
  • python_rtmidi (1.5.8)
  • pyuwsgi-2.0.30.post1
  • pywinpty (3.0.5)
  • rhino3dm (8.35.0)
  • sip (6.16.1)
  • sxtwl (2.0.7)
  • uwsgi (2.0.31)
  • viennarna (2.7.2)
  • watchdog (6.0.0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

2 participants