diff --git a/CHANGES.rst b/CHANGES.rst index a27a6b40..de58d1f0 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -23,6 +23,11 @@ 7.1.1 (2024-10-23) ================== +- Disable automatically using C speedups when Python 3.13 is used + in freethreading mode for the time being (at least until the C + extension gains support for freethreading mode). + (`#330 `_) + - Fix segmentation faults in `weakrefobject.c` on Python 3.12 and 3.13. (`#323 `_) diff --git a/src/zope/interface/_compat.py b/src/zope/interface/_compat.py index 38032953..6549da85 100644 --- a/src/zope/interface/_compat.py +++ b/src/zope/interface/_compat.py @@ -77,8 +77,10 @@ def _should_attempt_c_optimizations(): """ Return a true value if we should attempt to use the C optimizations. - This takes into account whether we're on PyPy and the value of the - ``PURE_PYTHON`` environment variable, as defined in `_use_c_impl`. + This takes into account whether we're on PyPy, whether you're using + a freethreading version of Python 3.13+ (where importing + the speedups would enable GIL) and the value of the ``PURE_PYTHON`` + environment variable, as defined in `_use_c_impl`. """ is_pypy = hasattr(sys, 'pypy_version_info') @@ -86,6 +88,8 @@ def _should_attempt_c_optimizations(): return True if is_pypy: return False + if sys.version_info >= (3, 13) and not sys._is_gil_enabled(): + return False return not _c_optimizations_ignored()