@@ -358,8 +358,8 @@ _PyThreadState_GetFrameBorrow(PyThreadState *tstate)
358358 || (defined (PYPY_VERSION ) && PY_VERSION_HEX < 0x030C0000 )) \
359359 && !(defined (Py_LIMITED_API) && PY_VERSION_HEX < 0x030A0000 ))
360360
361- # if !(defined(Py_LIMITED_API) && PY_VERSION_HEX < 0x030A0000 && defined(MS_WINDOWS))
362- static inline PyInterpreterState* PyInterpreterState_Get (void )
361+ static inline PyInterpreterState*
362+ PythonCAPICompat_PyInterpreterState_Get (void )
363363{
364364 PyThreadState *tstate;
365365 PyInterpreterState *interp;
@@ -374,27 +374,17 @@ static inline PyInterpreterState* PyInterpreterState_Get(void)
374374 }
375375 return interp;
376376}
377- #else
378- // PyInterpreterState_Get() is in the limited C API 3.9, but not in the 3.9
379- // stable ABI on Windows. It was added to stable ABI on Windows in Python 3.10.
380- // Use a macro to override C API function.
381- static inline PyInterpreterState*
382- PythonCAPI_Compat_PyInterpreterState_Get (void )
383- {
384- PyThreadState *tstate;
385- PyInterpreterState *interp;
386377
387- tstate = PyThreadState_GET ();
388- if (tstate == _Py_NULL) {
389- Py_FatalError (" GIL released (tstate is NULL)" );
390- }
391- interp = tstate->interp ;
392- if (interp == _Py_NULL) {
393- Py_FatalError (" no current interpreter" );
394- }
395- return interp;
378+ #if !(defined(Py_LIMITED_API) && PY_VERSION_HEX < 0x030A0000 && defined(MS_WINDOWS))
379+ static inline PyInterpreterState* PyInterpreterState_Get (void )
380+ {
381+ return PythonCAPICompat_PyInterpreterState_Get ();
396382}
397- #define PyInterpreterState_Get () PythonCAPI_Compat_PyInterpreterState_Get()
383+ #else
384+ // PyInterpreterState_Get() is in the limited C API 3.9, but not in
385+ // the 3.9 stable ABI on Windows. It was added to stable ABI on Windows
386+ // in Python 3.10. Use a macro to override C API function.
387+ # define PyInterpreterState_Get () PythonCAPICompat_PyInterpreterState_Get()
398388#endif
399389
400390#endif
0 commit comments