refactor: use PyThreadState_GetInterpreter() instead of tstate->interp (#6230)

* refactor: use PyThreadState_GetInterpreter() instead of tstate->interp

PyThreadState is opaque under the stable ABI; the accessor function is
public since Python 3.9. Older PyPy (e.g. 7.3.19 / PyPy 3.10) does not
provide it, so PyPy keeps reading tstate->interp.

See https://github.com/pybind/pybind11/discussions/6104 (B8).

Assisted-by: ClaudeCode:claude-opus-5-5

* refactor: limit interpreter accessor fallback to PyPy before 8.0

— codex GPT-6 on behalf of Ralf —

Keep direct thread-state field access for PyPy 7.x, since some releases
lack PyThreadState_GetInterpreter. Use the public accessor on PyPy 8.x,
where it is available for both supported Python versions.

---------

Co-authored-by: Ralf W. Grosse-Kunstleve <rgrossekunst@nvidia.com>
2 files changed