|
| 1 | +diff --git a/src/c/_cffi_backend.c b/src/c/_cffi_backend.c |
| 2 | +index 602117e3..8a9f5bbf 100644 |
| 3 | +--- a/src/c/_cffi_backend.c |
| 4 | ++++ b/src/c/_cffi_backend.c |
| 5 | +@@ -5884,7 +5884,7 @@ static CTypeDescrObject *fb_prepare_ctype(struct funcbuilder_s *fb, |
| 6 | + fb->bufferp = NULL; |
| 7 | + fb->fct = NULL; |
| 8 | + |
| 9 | +- pfargs = (CTypeDescrObject **)&PyTuple_GET_ITEM(fargs, 0); |
| 10 | ++ pfargs = (CTypeDescrObject **)PySequence_Fast_ITEMS(fargs); |
| 11 | + nargs = PyTuple_GET_SIZE(fargs); |
| 12 | + #if defined(MS_WIN32) && !defined(_WIN64) |
| 13 | + if (fabi == FFI_STDCALL) |
| 14 | +diff --git a/src/c/lib_obj.c b/src/c/lib_obj.c |
| 15 | +index bd9ba3fc..273c13a4 100644 |
| 16 | +--- a/src/c/lib_obj.c |
| 17 | ++++ b/src/c/lib_obj.c |
| 18 | +@@ -47,10 +47,10 @@ static struct CPyExtFunc_s *_cpyextfunc_get(PyObject *x) |
| 19 | + |
| 20 | + fo = (PyCFunctionObject *)x; |
| 21 | + lo = (LibObject *)y; |
| 22 | +- if (lo->l_libname != fo->m_module) |
| 23 | ++ if (lo->l_libname != _PyCFunction_GetModule(fo)) |
| 24 | + return NULL; |
| 25 | + |
| 26 | +- return (struct CPyExtFunc_s *)(fo->m_ml); |
| 27 | ++ return (struct CPyExtFunc_s *)(_PyCFunction_GetMethodDef(fo)); |
| 28 | + } |
| 29 | + |
| 30 | + static PyObject *_cpyextfunc_type(LibObject *lib, struct CPyExtFunc_s *exf) |
| 31 | +diff --git a/src/c/misc_thread_common.h b/src/c/misc_thread_common.h |
| 32 | +index 7d29634b..bb440851 100644 |
| 33 | +--- a/src/c/misc_thread_common.h |
| 34 | ++++ b/src/c/misc_thread_common.h |
| 35 | +@@ -344,45 +344,7 @@ static PyThreadState *get_current_ts(void) |
| 36 | + |
| 37 | + static PyGILState_STATE gil_ensure(void) |
| 38 | + { |
| 39 | +- /* Called at the start of a callback. Replacement for |
| 40 | +- PyGILState_Ensure(). |
| 41 | +- */ |
| 42 | +- PyGILState_STATE result; |
| 43 | +- PyThreadState *ts = PyGILState_GetThisThreadState(); |
| 44 | +- //fprintf(stderr, "%p: gil_ensure(), tstate=%p, tls=%p\n", get_cffi_tls(), ts, get_cffi_tls()); |
| 45 | +- |
| 46 | +- if (ts != NULL) { |
| 47 | +- ts->gilstate_counter++; |
| 48 | +- if (ts != get_current_ts()) { |
| 49 | +- /* common case: 'ts' is our non-current thread state and |
| 50 | +- we have to make it current and acquire the GIL */ |
| 51 | +- PyEval_RestoreThread(ts); |
| 52 | +- //fprintf(stderr, "%p: gil_ensure(), tstate=%p MADE CURRENT\n", get_cffi_tls(), ts); |
| 53 | +- return PyGILState_UNLOCKED; |
| 54 | +- } |
| 55 | +- else { |
| 56 | +- //fprintf(stderr, "%p: gil_ensure(), tstate=%p ALREADY CURRENT\n", get_cffi_tls(), ts); |
| 57 | +- return PyGILState_LOCKED; |
| 58 | +- } |
| 59 | +- } |
| 60 | +- else { |
| 61 | +- /* no thread state here so far. */ |
| 62 | +- result = PyGILState_Ensure(); |
| 63 | +- assert(result == PyGILState_UNLOCKED); |
| 64 | +- |
| 65 | +- ts = PyGILState_GetThisThreadState(); |
| 66 | +- //fprintf(stderr, "%p: gil_ensure(), made a new tstate=%p\n", get_cffi_tls(), ts); |
| 67 | +- assert(ts != NULL); |
| 68 | +- assert(ts == get_current_ts()); |
| 69 | +- assert(ts->gilstate_counter >= 1); |
| 70 | +- |
| 71 | +- /* Use the ThreadCanary mechanism to keep 'ts' alive until the |
| 72 | +- thread really shuts down */ |
| 73 | +- thread_canary_register(ts); |
| 74 | +- |
| 75 | +- assert(ts == PyGILState_GetThisThreadState()); |
| 76 | +- return result; |
| 77 | +- } |
| 78 | ++ return PyGILState_Ensure(); |
| 79 | + } |
| 80 | + |
| 81 | + static void gil_release(PyGILState_STATE oldstate) |
0 commit comments