diff --git a/Include/pyatomic.h b/Include/pyatomic.h index 9a497a6..ab90905 100644 --- a/Include/pyatomic.h +++ b/Include/pyatomic.h @@ -1,6 +1,5 @@ #ifndef Py_ATOMIC_H #define Py_ATOMIC_H -#ifdef Py_BUILD_CORE #include "dynamic_annotations.h" @@ -531,5 +530,4 @@ typedef struct _Py_atomic_int { _Py_atomic_store_explicit(ATOMIC_VAL, NEW_VAL, _Py_memory_order_relaxed) #define _Py_atomic_load_relaxed(ATOMIC_VAL) \ _Py_atomic_load_explicit(ATOMIC_VAL, _Py_memory_order_relaxed) -#endif /* Py_BUILD_CORE */ #endif /* Py_ATOMIC_H */ diff --git a/Modules/_pickle.c b/Modules/_pickle.c index 6b174f2..b03eb21 100644 --- a/Modules/_pickle.c +++ b/Modules/_pickle.c @@ -7,6 +7,7 @@ #include "Python.h" #include "structmember.h" +#include "internal/pystate.h" PyDoc_STRVAR(pickle_module_doc, "Optimized C implementation for the Python pickle module."); @@ -4179,6 +4180,14 @@ save(PicklerObject *self, PyObject *obj, int pers_save) PyObject *reduce_value = NULL; int status = 0; + if (_Py_atomic_load_relaxed(&_PyRuntime.ceval.eval_breaker)) { + if (_Py_atomic_load_relaxed( + &_PyRuntime.ceval.gil_drop_request)) { + Py_BEGIN_ALLOW_THREADS + Py_END_ALLOW_THREADS + } + } + if (_Pickler_OpcodeBoundary(self) < 0) return -1;