From d7ede81aa32b12f44fbb27200a3db6422dc8dfaa Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 19 Sep 2024 11:15:44 +0200 Subject: [PATCH 1/3] cocoa: Fix compile error with MacOSX 10.6 SDK --- panda/src/cocoadisplay/cocoaGraphicsWindow.mm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/panda/src/cocoadisplay/cocoaGraphicsWindow.mm b/panda/src/cocoadisplay/cocoaGraphicsWindow.mm index fde609cff8..bda8065bf8 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsWindow.mm +++ b/panda/src/cocoadisplay/cocoaGraphicsWindow.mm @@ -49,6 +49,12 @@ TypeHandle CocoaGraphicsWindow::_type_handle; #define NSAppKitVersionNumber10_14 1671 #endif +#if __MAC_OS_X_VERSION_MAX_ALLOWED < 1070 +enum { + NSFullScreenWindowMask = 1 << 14 +}; +#endif + /** * */ From e70d0b47fce54c177628595134c9731afa5cf281 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 19 Sep 2024 14:20:35 +0200 Subject: [PATCH 2/3] distributed: Fix very minor memory leak --- direct/src/distributed/cConnectionRepository.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/direct/src/distributed/cConnectionRepository.cxx b/direct/src/distributed/cConnectionRepository.cxx index f04f280936..1b6f06b6f3 100644 --- a/direct/src/distributed/cConnectionRepository.cxx +++ b/direct/src/distributed/cConnectionRepository.cxx @@ -717,6 +717,7 @@ handle_update_field() { nassertr(neverDisable != nullptr, false); unsigned int cNeverDisable = PyLong_AsLong(neverDisable); + Py_DECREF(neverDisable); if (!cNeverDisable) { // in quiet zone and distobj is disable-able drop update on the // floor From cdafd81764dcf794b031b630b00ef7d21f0239d9 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 19 Sep 2024 15:47:50 +0200 Subject: [PATCH 3/3] Fix compilation issues with Python 3.13 --- dtool/src/interrogatedb/py_compat.cxx | 6 +++++- dtool/src/interrogatedb/py_compat.h | 6 ++++++ dtool/src/interrogatedb/py_panda.cxx | 6 ++++-- panda/src/putil/bitArray_ext.cxx | 6 +++++- panda/src/putil/doubleBitMask_ext.I | 12 +++++++++++- pandatool/src/deploy-stub/deploy-stub.c | 2 ++ 6 files changed, 33 insertions(+), 5 deletions(-) diff --git a/dtool/src/interrogatedb/py_compat.cxx b/dtool/src/interrogatedb/py_compat.cxx index 722bc8300b..91fe93d456 100644 --- a/dtool/src/interrogatedb/py_compat.cxx +++ b/dtool/src/interrogatedb/py_compat.cxx @@ -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; diff --git a/dtool/src/interrogatedb/py_compat.h b/dtool/src/interrogatedb/py_compat.h index 20946e7f48..a386c06136 100644 --- a/dtool/src/interrogatedb/py_compat.h +++ b/dtool/src/interrogatedb/py_compat.h @@ -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. diff --git a/dtool/src/interrogatedb/py_panda.cxx b/dtool/src/interrogatedb/py_panda.cxx index bfd871b096..1ce7da8328 100644 --- a/dtool/src/interrogatedb/py_panda.cxx +++ b/dtool/src/interrogatedb/py_panda.cxx @@ -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; diff --git a/panda/src/putil/bitArray_ext.cxx b/panda/src/putil/bitArray_ext.cxx index 6e0d860238..86cd4ffe8e 100644 --- a/panda/src/putil/bitArray_ext.cxx +++ b/panda/src/putil/bitArray_ext.cxx @@ -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 + ); } } diff --git a/panda/src/putil/doubleBitMask_ext.I b/panda/src/putil/doubleBitMask_ext.I index 748def0371..c74bfa37af 100644 --- a/panda/src/putil/doubleBitMask_ext.I +++ b/panda/src/putil/doubleBitMask_ext.I @@ -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::half_bits); + PyObject *shifted = PyNumber_Lshift(hi, half_bits); + Py_DECREF(half_bits); +#else PyObject *shifted = _PyLong_Lshift(hi, DoubleBitMask::half_bits); +#endif Py_DECREF(hi); result = PyNumber_Or(shifted, lo); Py_DECREF(shifted); diff --git a/pandatool/src/deploy-stub/deploy-stub.c b/pandatool/src/deploy-stub/deploy-stub.c index 6fb5b1e310..7a36da6789 100644 --- a/pandatool/src/deploy-stub/deploy-stub.c +++ b/pandatool/src/deploy-stub/deploy-stub.c @@ -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