pr5450-support-python-3.12.patch 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. From 03c498d3142ccee2da258c540e96f12c863159fc Mon Sep 17 00:00:00 2001
  2. From: Stefan Behnel <stefan_ml@behnel.de>
  3. Date: Mon, 29 May 2023 22:08:50 +0200
  4. Subject: [PATCH] Avoid using the thread state attribute "use_tracing" in
  5. Python 3.12 where it was removed from the struct.
  6. See PEP-669 (https://peps.python.org/pep-0669/) and the implementation in https://github.com/python/cpython/pull/103083.
  7. There is more to be done to properly support PEP-669, but this makes it compile.
  8. See https://github.com/cython/cython/issues/5450
  9. ---
  10. Cython/Utility/Profile.c | 12 +++++++++---
  11. 1 file changed, 9 insertions(+), 3 deletions(-)
  12. diff --git a/Cython/Utility/Profile.c b/Cython/Utility/Profile.c
  13. index 20b599e7979..2b8564b226f 100644
  14. --- a/Cython/Utility/Profile.c
  15. +++ b/Cython/Utility/Profile.c
  16. @@ -61,15 +61,21 @@
  17. #define __Pyx_TraceFrameInit(codeobj) \
  18. if (codeobj) $frame_code_cname = (PyCodeObject*) codeobj;
  19. +
  20. #if PY_VERSION_HEX >= 0x030b00a2
  21. + #if PY_VERSION_HEX >= 0x030c00b1
  22. + #define __Pyx_IsTracing(tstate, check_tracing, check_funcs) \
  23. + ((!(check_tracing) || !(tstate)->tracing) && \
  24. + (!(check_funcs) || (tstate)->c_profilefunc || (CYTHON_TRACE && (tstate)->c_tracefunc)))
  25. + #else
  26. #define __Pyx_IsTracing(tstate, check_tracing, check_funcs) \
  27. (unlikely((tstate)->cframe->use_tracing) && \
  28. (!(check_tracing) || !(tstate)->tracing) && \
  29. (!(check_funcs) || (tstate)->c_profilefunc || (CYTHON_TRACE && (tstate)->c_tracefunc)))
  30. + #endif
  31. - #define __Pyx_EnterTracing(tstate) PyThreadState_EnterTracing(tstate)
  32. -
  33. - #define __Pyx_LeaveTracing(tstate) PyThreadState_LeaveTracing(tstate)
  34. + #define __Pyx_EnterTracing(tstate) PyThreadState_EnterTracing(tstate)
  35. + #define __Pyx_LeaveTracing(tstate) PyThreadState_LeaveTracing(tstate)
  36. #elif PY_VERSION_HEX >= 0x030a00b1
  37. #define __Pyx_IsTracing(tstate, check_tracing, check_funcs) \