PySysC icon indicating copy to clipboard operation
PySysC copied to clipboard

Fix thread init for Python 3.9+

Open cphurley82 opened this issue 3 months ago • 1 comments

Summary

  • Guard the legacy PyEval_ThreadsInitialized() call behind a PY_VERSION_HEX < 0x03090000 check.
  • Call PyEval_InitThreads() unconditionally on Python ≥3.9, where PyEval_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.

cphurley82 avatar Nov 01 '25 23:11 cphurley82