python / cpython

The Python programming language
https://www.python.org
Other
62.3k stars 29.93k forks source link

C API: Restore removed PyEval_InitThreads() function #117929

Closed vstinner closed 4 months ago

vstinner commented 5 months ago

Since Python 3.7, PyEval_InitThreads() does nothing, since the GIL is now always created: https://vstinner.github.io/python37-gil-change.html This function is deprecated since Python 3.9 and I removed it in Python 3.13 alpha1.

Problem: my Fedora team identified that 16 projects are affected by this function removal.

I propose to restore the function in Python 3.13 beta1, and remove it again in Python 3.14 alpha1.

Linked PRs

vstinner commented 5 months ago

collectd doesn't seem to be affected for 3 years: https://github.com/collectd/collectd/commit/17d2fbe443b656bb0f74c204eb003cea22f94e60

#if PY_VERSION_HEX < 0x03090000
  // deprecated. Called by Py_Initialize(). Removed in Py3.11
  // https://docs.python.org/3/c-api/init.html#c.PyEval_InitThreads
  PyEval_InitThreads();
#else
  Py_Initialize();
#endif

The problem is that collected 5.12 is affected, there was no release since 2020. Only release candidates of a future 6.0 version.

Fedora bug report: https://bugzilla.redhat.com/show_bug.cgi?id=2247197

vstinner commented 5 months ago

gnumeric was fixed 4 months ago: https://gitlab.gnome.org/GNOME/gnumeric/-/commit/015de3d0df1d59e62e5bfeabab31834082b81196

vstinner commented 5 months ago

pyotherside: I proposed a fix, https://github.com/thp/pyotherside/pull/132/files

corona10 commented 5 months ago

python-confluent-kafka: https://github.com/confluentinc/confluent-kafka-python/blob/5a87879681d28375a55203c4839338b13b668046/src/confluent_kafka/src/confluent_kafka.c#L3023-L3025

vstinner commented 4 months ago

Fixed by change https://github.com/python/cpython/commit/75eed5b3734edb221cabb8322d8b8bdf9e3ee6b1