0010_python3_11.patch 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. commit 3e7abb113568b07627e00a7a4e5df5e3cfefccfe
  2. Author: CYBERDEViL <cyberdevil@notabug.org>
  3. Date: Sun Dec 17 14:37:36 2023 +0100
  4. python3.11: eval.h has been removed from Python 3.11
  5. And compile.h is included with Python.h
  6. commit 5b4980bb042bf23779de97f38d6678f483a6f23e
  7. Author: CYBERDEViL <cyberdevil@notabug.org>
  8. Date: Sat Dec 16 02:31:55 2023 +0100
  9. python3.11: Remove invalid use of Py_TPFLAGS_HAVE_GC flag
  10. Error otherwise thrown:
  11. SystemError: type bpy_struct has the Py_TPFLAGS_HAVE_GC flag but has
  12. no traverse function
  13. This is for Python 3.11, see https://docs.python.org/3/whatsnew/3.11.html
  14. """
  15. The PyType_Ready() function now raises an error if a type is defined
  16. with the Py_TPFLAGS_HAVE_GC flag set but has no traverse function
  17. (PyTypeObject.tp_traverse). (Contributed by Victor Stinner in
  18. bpo-44263.)
  19. """
  20. commit 54c261ddfcb7221b1e6828c0a6a29a8b07f57043
  21. Author: CYBERDEViL <cyberdevil@notabug.org>
  22. Date: Sat Dec 16 01:12:28 2023 +0100
  23. python3.11: "Python: support v3.11 (beta) with changes to PyFrameObj.."
  24. Partially applied Blender upstream ref: 780c0ea097444c3be60314dffd203c099720badb
  25. diff --git a/blender-2.79b/source/blender/python/generic/py_capi_utils.c b/blender-2.79b/source/blender/python/generic/py_capi_utils.c
  26. index 17cb657..10a38da 100644
  27. --- a/blender-2.79b/source/blender/python/generic/py_capi_utils.c
  28. +++ b/blender-2.79b/source/blender/python/generic/py_capi_utils.c
  29. @@ -282,17 +282,21 @@ void PyC_StackSpit(void)
  30. void PyC_FileAndNum(const char **filename, int *lineno)
  31. {
  32. PyFrameObject *frame;
  33. -
  34. + PyCodeObject *code;
  35. +
  36. if (filename) *filename = NULL;
  37. if (lineno) *lineno = -1;
  38. - if (!(frame = PyThreadState_GET()->frame)) {
  39. + if (!(frame = PyEval_GetFrame())) {
  40. + return;
  41. + }
  42. + if (!(code = PyFrame_GetCode(frame))) {
  43. return;
  44. }
  45. /* when executing a script */
  46. if (filename) {
  47. - *filename = PyUnicode_AsUTF8(frame->f_code->co_filename);
  48. + *filename = PyUnicode_AsUTF8(code->co_filename);
  49. }
  50. /* when executing a module */
  51. diff --git a/blender-2.79b/source/blender/python/intern/bpy_app_handlers.c b/blender-2.79b/source/blender/python/intern/bpy_app_handlers.c
  52. index 90aa22d..bcabd09 100644
  53. --- a/blender-2.79b/source/blender/python/intern/bpy_app_handlers.c
  54. +++ b/blender-2.79b/source/blender/python/intern/bpy_app_handlers.c
  55. @@ -155,8 +155,7 @@ static PyTypeObject BPyPersistent_Type = {
  56. 0, /* tp_getattro */
  57. 0, /* tp_setattro */
  58. 0, /* tp_as_buffer */
  59. - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
  60. - Py_TPFLAGS_BASETYPE, /* tp_flags */
  61. + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
  62. 0, /* tp_doc */
  63. 0, /* tp_traverse */
  64. 0, /* tp_clear */
  65. diff --git a/blender-2.79b/source/blender/python/intern/bpy_rna.c b/blender-2.79b/source/blender/python/intern/bpy_rna.c
  66. index 722e23d..f2f0ed7 100644
  67. --- a/blender-2.79b/source/blender/python/intern/bpy_rna.c
  68. +++ b/blender-2.79b/source/blender/python/intern/bpy_rna.c
  69. @@ -5753,7 +5753,7 @@ PyTypeObject pyrna_struct_Type = {
  70. NULL, /* PyBufferProcs *tp_as_buffer; */
  71. /*** Flags to define presence of optional/expanded features ***/
  72. - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /* long tp_flags; */
  73. + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* long tp_flags; */
  74. NULL, /* char *tp_doc; Documentation string */
  75. /*** Assigned meaning in release 2.0 ***/
  76. diff --git a/blender-2.79b/source/blender/python/intern/bpy_traceback.c b/blender-2.79b/source/blender/python/intern/bpy_traceback.c
  77. index fedf889..462438f 100644
  78. --- a/blender-2.79b/source/blender/python/intern/bpy_traceback.c
  79. +++ b/blender-2.79b/source/blender/python/intern/bpy_traceback.c
  80. @@ -39,7 +39,9 @@
  81. static const char *traceback_filepath(PyTracebackObject *tb, PyObject **coerce)
  82. {
  83. - return PyBytes_AS_STRING((*coerce = PyUnicode_EncodeFSDefault(tb->tb_frame->f_code->co_filename)));
  84. + PyCodeObject *code = PyFrame_GetCode(tb->tb_frame);
  85. + *coerce = PyUnicode_EncodeFSDefault(code->co_filename);
  86. + return PyBytes_AS_STRING(*coerce);
  87. }
  88. /* copied from pythonrun.c, 3.4.0 */
  89. diff --git a/blender-2.79b/source/gameengine/GameLogic/SCA_PythonController.cpp b/blender-2.79b/source/gameengine/GameLogic/SCA_PythonController.cpp
  90. index 6aaf6f0..f8a9cc4 100644
  91. --- a/blender-2.79b/source/gameengine/GameLogic/SCA_PythonController.cpp
  92. +++ b/blender-2.79b/source/gameengine/GameLogic/SCA_PythonController.cpp
  93. @@ -41,11 +41,6 @@
  94. #include "SCA_IActuator.h"
  95. #include "EXP_PyObjectPlus.h"
  96. -#ifdef WITH_PYTHON
  97. -#include "compile.h"
  98. -#include "eval.h"
  99. -#endif // WITH_PYTHON
  100. -
  101. #include <algorithm>