Fix compilation issues with Python 3.13
This commit is contained in:
parent
e70d0b47fc
commit
cdafd81764
|
|
@ -33,7 +33,11 @@ size_t PyLongOrInt_AsSize_t(PyObject *vv) {
|
|||
size_t bytes;
|
||||
int one = 1;
|
||||
int res = _PyLong_AsByteArray((PyLongObject *)vv, (unsigned char *)&bytes,
|
||||
SIZEOF_SIZE_T, (int)*(unsigned char*)&one, 0);
|
||||
SIZEOF_SIZE_T, (int)*(unsigned char*)&one, 0,
|
||||
#if PY_VERSION_HEX >= 0x030d0000
|
||||
, 1 // with_exceptions
|
||||
#endif
|
||||
);
|
||||
|
||||
if (res < 0) {
|
||||
return (size_t)res;
|
||||
|
|
|
|||
|
|
@ -255,6 +255,12 @@ INLINE bool PyLong_IsNonNegative(PyObject *value) {
|
|||
}
|
||||
#endif
|
||||
|
||||
/* Python 3.13 */
|
||||
|
||||
#if PY_VERSION_HEX < 0x030D00A1
|
||||
# define PyLong_AsInt(x) (_PyLong_AsInt(x))
|
||||
#endif
|
||||
|
||||
/* Other Python implementations */
|
||||
|
||||
// _PyErr_OCCURRED is an undocumented macro version of PyErr_Occurred.
|
||||
|
|
|
|||
|
|
@ -765,7 +765,7 @@ PyObject *copy_from_make_copy(PyObject *self, PyObject *noargs) {
|
|||
*/
|
||||
PyObject *copy_from_copy_constructor(PyObject *self, PyObject *noargs) {
|
||||
PyObject *callable = (PyObject *)Py_TYPE(self);
|
||||
return _PyObject_FastCall(callable, &self, 1);
|
||||
return PyObject_CallOneArg(callable, self);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -850,7 +850,9 @@ bool Dtool_ExtractOptionalArg(PyObject **result, PyObject *args, PyObject *kwds,
|
|||
}
|
||||
|
||||
// We got the item, we just need to make sure that it had the right key.
|
||||
#if PY_VERSION_HEX >= 0x03060000
|
||||
#if PY_VERSION_HEX >= 0x030d0000
|
||||
return PyUnicode_CheckExact(key) && PyUnicode_EqualToUTF8(key, keyword);
|
||||
#elif PY_VERSION_HEX >= 0x03060000
|
||||
return PyUnicode_CheckExact(key) && _PyUnicode_EqualToASCIIString(key, keyword);
|
||||
#elif PY_MAJOR_VERSION >= 3
|
||||
return PyUnicode_CheckExact(key) && PyUnicode_CompareWithASCIIString(key, keyword) == 0;
|
||||
|
|
|
|||
|
|
@ -44,7 +44,11 @@ __init__(PyObject *init_value) {
|
|||
_PyLong_AsByteArray((PyLongObject *)init_value,
|
||||
(unsigned char *)&_this->_array[0],
|
||||
num_words * sizeof(BitArray::WordType),
|
||||
1, 0);
|
||||
1, 0
|
||||
#if PY_VERSION_HEX >= 0x030d0000
|
||||
, 1 // with_exceptions
|
||||
#endif
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,11 @@ __init__(PyObject *init_value) {
|
|||
if (n > 0) {
|
||||
size_t num_bytes = (n + 7) / 8;
|
||||
unsigned char *bytes = (unsigned char *)alloca(num_bytes);
|
||||
_PyLong_AsByteArray((PyLongObject *)init_value, bytes, num_bytes, 1, 0);
|
||||
_PyLong_AsByteArray((PyLongObject *)init_value, bytes, num_bytes, 1, 0
|
||||
#if PY_VERSION_HEX >= 0x030d0000
|
||||
, 1 // with_exceptions
|
||||
#endif
|
||||
);
|
||||
|
||||
for (size_t i = 0; i < num_bytes; ++i) {
|
||||
this->_this->store(bytes[i], i * 8, 8);
|
||||
|
|
@ -60,7 +64,13 @@ __int__() const {
|
|||
if (!this->_this->_hi.is_zero()) {
|
||||
PyObject *lo = result;
|
||||
PyObject *hi = invoke_extension(&this->_this->_hi).__int__();
|
||||
#if PY_VERSION_HEX >= 0x030d0000
|
||||
PyObject *half_bits = PyLong_FromUnsignedLong(DoubleBitMask<BMType>::half_bits);
|
||||
PyObject *shifted = PyNumber_Lshift(hi, half_bits);
|
||||
Py_DECREF(half_bits);
|
||||
#else
|
||||
PyObject *shifted = _PyLong_Lshift(hi, DoubleBitMask<BMType>::half_bits);
|
||||
#endif
|
||||
Py_DECREF(hi);
|
||||
result = PyNumber_Or(shifted, lo);
|
||||
Py_DECREF(shifted);
|
||||
|
|
|
|||
|
|
@ -827,7 +827,9 @@ int main(int argc, char *argv[]) {
|
|||
new_moddef->code = moddef->code;
|
||||
new_moddef->size = moddef->size < 0 ? -(moddef->size) : moddef->size;
|
||||
new_moddef->is_package = moddef->size < 0;
|
||||
#if PY_VERSION_HEX < 0x030d0000 // 3.13
|
||||
new_moddef->get_code = NULL;
|
||||
#endif
|
||||
new_moddef++;
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue