PySysC
PySysC copied to clipboard
Fix thread init for Python 3.9+
Summary
- Guard the legacy
PyEval_ThreadsInitialized()call behind aPY_VERSION_HEX < 0x03090000check. - Call
PyEval_InitThreads()unconditionally on Python ≥3.9, wherePyEval_ThreadsInitialized()was removed, keeping the GIL initialisation behaviour intact. - Preserve Python ≤3.8 behaviour (only initialise if the threads API reports “not ready”) so older interpreters see no change.
Motivation
Python 3.9 removed PyEval_ThreadsInitialized(), causing PySysC to fail at import/build time on modern interpreters with:
AttributeError: module 'cpython' has no attribute 'PyEval_ThreadsInitialized'
The new guard allows PySysC to run on Python 3.9+ without regressing older Python releases.