summaryrefslogtreecommitdiffstats
path: root/contrib/tools/cython/Cython/Utility/ModuleSetupCode.c
diff options
context:
space:
mode:
authorarcadia-devtools <[email protected]>2022-05-31 21:49:01 +0300
committerarcadia-devtools <[email protected]>2022-05-31 21:49:01 +0300
commitceb13dcc40dd5e11c8e3189b3c15b3bd5897d4ac (patch)
treeeda501e07fcaba4f64bc3d29725472162f2e4227 /contrib/tools/cython/Cython/Utility/ModuleSetupCode.c
parent5b69557e440e6ac18399a29076fef25602859f17 (diff)
intermediate changes
ref:85306a27df0004d13faf777131d0b092370e6b90
Diffstat (limited to 'contrib/tools/cython/Cython/Utility/ModuleSetupCode.c')
-rw-r--r--contrib/tools/cython/Cython/Utility/ModuleSetupCode.c46
1 files changed, 41 insertions, 5 deletions
diff --git a/contrib/tools/cython/Cython/Utility/ModuleSetupCode.c b/contrib/tools/cython/Cython/Utility/ModuleSetupCode.c
index 21c43cb3306..b6530018991 100644
--- a/contrib/tools/cython/Cython/Utility/ModuleSetupCode.c
+++ b/contrib/tools/cython/Cython/Utility/ModuleSetupCode.c
@@ -93,6 +93,9 @@
#define CYTHON_USE_DICT_VERSIONS 0
#undef CYTHON_USE_EXC_INFO_STACK
#define CYTHON_USE_EXC_INFO_STACK 0
+ #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
+ #define CYTHON_UPDATE_DESCRIPTOR_DOC (PYPY_VERSION_HEX >= 0x07030900)
+ #endif
#elif defined(PYSTON_VERSION)
#define CYTHON_COMPILING_IN_PYPY 0
@@ -136,6 +139,9 @@
#define CYTHON_USE_DICT_VERSIONS 0
#undef CYTHON_USE_EXC_INFO_STACK
#define CYTHON_USE_EXC_INFO_STACK 0
+ #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
+ #define CYTHON_UPDATE_DESCRIPTOR_DOC 0
+ #endif
#else
#define CYTHON_COMPILING_IN_PYPY 0
@@ -196,7 +202,8 @@
#ifndef CYTHON_FAST_PYCALL
// Python 3.11 deleted localplus argument from frame object, which is used in our
// fast_pycall code
- #define CYTHON_FAST_PYCALL (PY_VERSION_HEX < 0x030B00A1)
+ // On Python 3.10 it causes issues when used while profiling/debugging
+ #define CYTHON_FAST_PYCALL (PY_VERSION_HEX < 0x030A0000)
#endif
#ifndef CYTHON_PEP489_MULTI_PHASE_INIT
#define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
@@ -213,6 +220,9 @@
#elif !defined(CYTHON_USE_EXC_INFO_STACK)
#define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
#endif
+ #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
+ #define CYTHON_UPDATE_DESCRIPTOR_DOC 1
+ #endif
#endif
#if !defined(CYTHON_FAST_PYCCALL)
@@ -1223,11 +1233,37 @@ static int __Pyx_check_binary_version(void);
/////////////// CheckBinaryVersion ///////////////
static int __Pyx_check_binary_version(void) {
- char ctversion[4], rtversion[4];
- PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
- PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
- if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
+ char ctversion[5];
+ int same=1, i, found_dot;
+ const char* rt_from_call = Py_GetVersion();
+ PyOS_snprintf(ctversion, 5, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
+ // slightly convoluted, but now that we're into double digit version numbers we can no longer just rely on the length.
+ found_dot = 0;
+ for (i = 0; i < 4; i++) {
+ if (!ctversion[i]) {
+ // if they are the same, just check that the runtime version doesn't continue with further numbers
+ same = (rt_from_call[i] < '0' || rt_from_call[i] > '9');
+ break;
+ }
+ if (rt_from_call[i] != ctversion[i]) {
+ same = 0;
+ break;
+ }
+ }
+
+ if (!same) {
+ char rtversion[5] = {'\0'};
+ // copy the runtime-version for the error message
char message[200];
+ for (i=0; i<4; ++i) {
+ if (rt_from_call[i] == '.') {
+ if (found_dot) break;
+ found_dot = 1;
+ } else if (rt_from_call[i] < '0' || rt_from_call[i] > '9') {
+ break;
+ }
+ rtversion[i] = rt_from_call[i];
+ }
PyOS_snprintf(message, sizeof(message),
"compiletime version %s of module '%.100s' "
"does not match runtime version %s",