0002-siplib-fix-build-with-python-3.11.patch 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. From e8bbb7844c141b339ef0598decf2a808faa50f5e Mon Sep 17 00:00:00 2001
  2. From: Ralf Dragon <hypnotoad@lindra.de>
  3. Date: Sun, 17 Dec 2023 22:55:17 +0100
  4. Subject: [PATCH] siplib: fix build with python >= 3.11
  5. With python 3.11, the PyFrameObject structure members have been
  6. removed from the public C API:
  7. https://docs.python.org/3.11/whatsnew/3.11.html#whatsnew311-c-api-porting
  8. https://docs.python.org/3.11/whatsnew/3.11.html#pyframeobject-3-11-hiding
  9. This patch migrates to the opaque PyFrameObject.
  10. Upstream: Not Applicable, SIP 4.x is no longer maintained
  11. Signed-off-by: Ralf Dragon <hypnotoad@lindra.de>
  12. ---
  13. siplib/sip.h | 2 +-
  14. siplib/siplib.c | 8 ++++----
  15. 2 files changed, 5 insertions(+), 5 deletions(-)
  16. diff --git a/siplib/sip.h b/siplib/sip.h
  17. index 251b122..b9d8ea2 100644
  18. --- a/siplib/sip.h
  19. +++ b/siplib/sip.h
  20. @@ -1799,7 +1799,7 @@ typedef struct _sipAPIDef {
  21. int (*api_get_time)(PyObject *, sipTimeDef *);
  22. PyObject *(*api_from_time)(const sipTimeDef *);
  23. int (*api_is_user_type)(const sipWrapperType *);
  24. - struct _frame *(*api_get_frame)(int);
  25. + PyFrameObject *(*api_get_frame)(int);
  26. int (*api_check_plugin_for_type)(const sipTypeDef *, const char *);
  27. PyObject *(*api_unicode_new)(SIP_SSIZE_T, unsigned, int *, void **);
  28. void (*api_unicode_write)(int, void *, int, unsigned);
  29. diff --git a/siplib/siplib.c b/siplib/siplib.c
  30. index db52b68..a297855 100644
  31. --- a/siplib/siplib.c
  32. +++ b/siplib/siplib.c
  33. @@ -448,7 +448,7 @@ static PyObject *sip_api_from_datetime(const sipDateDef *date,
  34. static int sip_api_get_time(PyObject *obj, sipTimeDef *time);
  35. static PyObject *sip_api_from_time(const sipTimeDef *time);
  36. static int sip_api_is_user_type(const sipWrapperType *wt);
  37. -static struct _frame *sip_api_get_frame(int);
  38. +static PyFrameObject *sip_api_get_frame(int);
  39. static int sip_api_check_plugin_for_type(const sipTypeDef *td,
  40. const char *name);
  41. static PyObject *sip_api_unicode_new(SIP_SSIZE_T len, unsigned maxchar,
  42. @@ -13741,13 +13741,13 @@ static int sip_api_is_user_type(const sipWrapperType *wt)
  43. /*
  44. * Return a frame from the execution stack.
  45. */
  46. -static struct _frame *sip_api_get_frame(int depth)
  47. +static PyFrameObject *sip_api_get_frame(int depth)
  48. {
  49. - struct _frame *frame = PyEval_GetFrame();
  50. + PyFrameObject *frame = PyEval_GetFrame();
  51. while (frame != NULL && depth > 0)
  52. {
  53. - frame = frame->f_back;
  54. + frame = PyFrame_GetBack(frame);
  55. --depth;
  56. }
  57. --
  58. 2.43.0