summaryrefslogtreecommitdiff
path: root/media-gfx/freecad/files/freecad-0.21.2-py312-qt6.patch
blob: c1fe31ab05adea32b01dac90eac3da964a7dc0d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
From 6043c90462e85fbf15e30ea4c7da7d9a22d570f2 Mon Sep 17 00:00:00 2001
From: wmayer <wmayer@users.sourceforge.net>
Date: Wed, 7 Feb 2024 15:25:13 +0100
Subject: [PATCH] Py3.12: harmonize with upstream of PyCXX

---
 src/CXX/IndirectPythonInterface.cxx         | 36 +++++++++++++++------
 src/CXX/Python3/IndirectPythonInterface.hxx |  6 ++--
 src/CXX/Python3/cxx_extensions.cxx          |  2 +-
 src/CXX/Python3/cxxextensions.c             | 10 ++++++
 src/CXX/Version.hxx                         |  2 +-
 5 files changed, 42 insertions(+), 14 deletions(-)

diff --git a/src/CXX/IndirectPythonInterface.cxx b/src/CXX/IndirectPythonInterface.cxx
index 3d810cea88a5..fc9e45cbd64f 100644
--- a/src/CXX/IndirectPythonInterface.cxx
+++ b/src/CXX/IndirectPythonInterface.cxx
@@ -122,17 +122,21 @@ static PyTypeObject *ptr__Bytes_Type = NULL;
 #  endif
 
 #  if PY_MAJOR_VERSION == 2 || !defined( Py_LIMITED_API )
+#    if PY_MAJOR_VERSION == 2 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION <= 11)
 static int *ptr_Py_DebugFlag = NULL;
 static int *ptr_Py_InteractiveFlag = NULL;
 static int *ptr_Py_OptimizeFlag = NULL;
 static int *ptr_Py_NoSiteFlag = NULL;
 static int *ptr_Py_VerboseFlag = NULL;
+#    endif
 
-#   if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 7
+#    if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION <= 11
+#      if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 7
 static const char **ptr__Py_PackageContext = NULL;
-#   else
+#      else
 static char **ptr__Py_PackageContext = NULL;
-#   endif
+#      endif
+#    endif
 #  endif
 
 #  ifdef Py_REF_DEBUG
@@ -242,17 +246,21 @@ bool InitialisePythonIndirectInterface()
     ptr_Py_RefTotal             = GetInt_as_IntPointer( "_Py_RefTotal" );
 #  endif
 #  if PY_MAJOR_VERSION == 2 || !defined( Py_LIMITED_API )
+#    if PY_MAJOR_VERSION == 2 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION <= 11)
     ptr_Py_DebugFlag            = GetInt_as_IntPointer( "Py_DebugFlag" );
     ptr_Py_InteractiveFlag      = GetInt_as_IntPointer( "Py_InteractiveFlag" );
     ptr_Py_OptimizeFlag         = GetInt_as_IntPointer( "Py_OptimizeFlag" );
     ptr_Py_NoSiteFlag           = GetInt_as_IntPointer( "Py_NoSiteFlag" );
     ptr_Py_VerboseFlag          = GetInt_as_IntPointer( "Py_VerboseFlag" );
+#    endif
 
-#    if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 7
+#    if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION <= 11
+#       if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 7
     ptr__Py_PackageContext      = GetConstCharPointer_as_ConstCharPointerPointer( "_Py_PackageContext" );
-#    else
+#       else
     ptr__Py_PackageContext      = GetCharPointer_as_CharPointerPointer( "_Py_PackageContext" );
-#    endif
+#       endif
+#     endif
 #  endif
 
 #  define PYCXX_STANDARD_EXCEPTION( eclass, bclass )
@@ -397,17 +405,21 @@ PYCXX_EXPORT PyTypeObject *_Bytes_Type()             { return ptr__Bytes_Type; }
 //    wrap the Python Flag variables
 //
 #  if PY_MAJOR_VERSION == 2 || !defined( Py_LIMITED_API )
+#    if PY_MAJOR_VERSION == 2 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION <= 11)
 PYCXX_EXPORT int &_Py_DebugFlag()                    { return *ptr_Py_DebugFlag; }
 PYCXX_EXPORT int &_Py_InteractiveFlag()              { return *ptr_Py_InteractiveFlag; }
 PYCXX_EXPORT int &_Py_OptimizeFlag()                 { return *ptr_Py_OptimizeFlag; }
 PYCXX_EXPORT int &_Py_NoSiteFlag()                   { return *ptr_Py_NoSiteFlag; }
 PYCXX_EXPORT int &_Py_VerboseFlag()                  { return *ptr_Py_VerboseFlag; }
+#    endif
 #  endif
 
-#  if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 7
+#  if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION <= 11
+#    if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 7
 PYCXX_EXPORT const char *__Py_PackageContext()       { return *ptr__Py_PackageContext; }
-#  else
+#    else
 PYCXX_EXPORT char *__Py_PackageContext()             { return *ptr__Py_PackageContext; }
+#    endif
 #  endif
 
 #  if 0
@@ -518,15 +530,19 @@ PYCXX_EXPORT PyTypeObject *_Bytes_Type()             { return &PyBytes_Type; }
 //    wrap flags
 //
 # if PY_MAJOR_VERSION == 2 || !defined( Py_LIMITED_API )
+#    if PY_MAJOR_VERSION == 2 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION <= 11)
 PYCXX_EXPORT int &_Py_DebugFlag()                    { return Py_DebugFlag; }
 PYCXX_EXPORT int &_Py_InteractiveFlag()              { return Py_InteractiveFlag; }
 PYCXX_EXPORT int &_Py_OptimizeFlag()                 { return Py_OptimizeFlag; }
 PYCXX_EXPORT int &_Py_NoSiteFlag()                   { return Py_NoSiteFlag; }
 PYCXX_EXPORT int &_Py_VerboseFlag()                  { return Py_VerboseFlag; }
-#  if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 7
+#    endif
+#  if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION <= 11
+#   if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 7
 PYCXX_EXPORT const char *__Py_PackageContext()       { return _Py_PackageContext; }
-#  else
+#   else
 PYCXX_EXPORT char *__Py_PackageContext()             { return _Py_PackageContext; }
+#   endif
 #  endif
 # endif
 
diff --git a/src/CXX/Python3/IndirectPythonInterface.hxx b/src/CXX/Python3/IndirectPythonInterface.hxx
index bf2c15c53f9a..eb4ae4fe63b9 100644
--- a/src/CXX/Python3/IndirectPythonInterface.hxx
+++ b/src/CXX/Python3/IndirectPythonInterface.hxx
@@ -149,10 +149,12 @@ PYCXX_EXPORT int &_Py_NoSiteFlag();
 PYCXX_EXPORT int &_Py_TabcheckFlag();
 PYCXX_EXPORT int &_Py_VerboseFlag();
 
-#  if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 7
+# if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION <= 11
+#   if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 7
 PYCXX_EXPORT const char *__Py_PackageContext();
-#  else
+#   else
 PYCXX_EXPORT char *__Py_PackageContext();
+#   endif
 #  endif
 # endif
 
diff --git a/src/CXX/Python3/cxx_extensions.cxx b/src/CXX/Python3/cxx_extensions.cxx
index 7371810be4a9..e6eefdafea17 100644
--- a/src/CXX/Python3/cxx_extensions.cxx
+++ b/src/CXX/Python3/cxx_extensions.cxx
@@ -152,7 +152,7 @@ PyMethodDef *MethodTable::table()
 //================================================================================
 ExtensionModuleBase::ExtensionModuleBase( const char *name )
 : m_module_name( name )
-#if defined( Py_LIMITED_API )
+#if defined( Py_LIMITED_API ) || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 12)
 , m_full_module_name( m_module_name )
 #else
 , m_full_module_name( __Py_PackageContext() != NULL ? std::string( __Py_PackageContext() ) : m_module_name )
diff --git a/src/CXX/Python3/cxxextensions.c b/src/CXX/Python3/cxxextensions.c
index 3b0f8ef7c588..afb9313ad0a8 100644
--- a/src/CXX/Python3/cxxextensions.c
+++ b/src/CXX/Python3/cxxextensions.c
@@ -42,6 +42,14 @@ extern "C"
 {
 #endif
 
+#if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 13
+PyObject py_object_initializer =
+    {
+    { 1 },
+    NULL    // type must be init'ed by user
+    };
+
+#else
 PyObject py_object_initializer =
     {
     _PyObject_EXTRA_INIT
@@ -49,6 +57,8 @@ PyObject py_object_initializer =
     NULL    // type must be init'ed by user
     };
 
+#endif
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/src/CXX/Version.hxx b/src/CXX/Version.hxx
index e6069aad335e..59fe3c203b86 100644
--- a/src/CXX/Version.hxx
+++ b/src/CXX/Version.hxx
@@ -40,7 +40,7 @@
 
 #define PYCXX_VERSION_MAJOR 7
 #define PYCXX_VERSION_MINOR 1
-#define PYCXX_VERSION_PATCH 7
+#define PYCXX_VERSION_PATCH 9
 #define PYCXX_MAKEVERSION( major, minor, patch ) ((major<<16)|(minor<<8)|(patch))
 #define PYCXX_VERSION PYCXX_MAKEVERSION( PYCXX_VERSION_MAJOR, PYCXX_VERSION_MINOR, PYCXX_VERSION_PATCH )
 #endif