-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Python 3.13 CI #587
Add Python 3.13 CI #587
Conversation
source/mqtt_client_connection.c
Outdated
#if PY_VERSION_HEX >= 0x030D0000 /* Check if Python version is 3.13 or higher */ | ||
if (PyWeakref_GetRef(py_connection->self_proxy, &self) < 0) { /* strong reference */ | ||
PyErr_WriteUnraisable(PyErr_Occurred()); | ||
goto on_done; | ||
} | ||
#else | ||
/* PyWeakref_GetObject is deprecated since python 3.13 */ | ||
self = PyWeakref_GetObject(py_connection->self_proxy); /* borrowed reference */ | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the logic is copy/pasted a lot of time. How about backporting PyWeakref_GetRef to older versions
module.h:
#if PY_VERSION_HEX < 0x30D0000
// PyWeakref_GetRef() was added in Python3.13, make it available in older versions
int PyWeakref_GetRef(PyObject *ref, PyObject **pobj);
#endif
module.c:
#if PY_VERSION_HEX < 0x30D0000
// PyWeakref_GetRef() was added in Python3.13, make it available in older versions
int PyWeakref_GetRef(PyObject *ref, PyObject **pobj) {
...
}
#endif
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if we can backport it. PyWeakref_GetRef
depends upon the internal function _PyWeakref_GetRef
, which is probably located at https://fossies.org/linux/misc/Python-3.13.0rc2.tar.xz/Python-3.13.0rc2/Include/internal/pycore_weakref.h, and that function also depends upon several internal functions.
We can potentially add PyWeakref_GetRef
, which calls PyWeakref_GetObject
and also increments the ref count, so that we can avoid the copy-paste.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, updated. I have created a new function which abstracts the differences between APIs into a single place, and we don't need to do any code duplication. I didn't define PyWeakref_GetRef
for pre-Python 3.13 because I thought it would be confusing for future readers that we are calling the Python 3.13+ function, and having our own definition for pre-Python 3.13 which does something slightly different.
Co-authored-by: Michael Graeb <[email protected]>
Co-authored-by: Michael Graeb <[email protected]>
Co-authored-by: Michael Graeb <[email protected]>
Co-authored-by: Michael Graeb <[email protected]>
Co-authored-by: Michael Graeb <[email protected]>
Co-authored-by: Michael Graeb <[email protected]>
Co-authored-by: Michael Graeb <[email protected]>
Co-authored-by: Michael Graeb <[email protected]>
Co-authored-by: Michael Graeb <[email protected]>
Co-authored-by: Michael Graeb <[email protected]>
AWS_FATAL_ASSERT if these functions raise a python exception (which we never checked for before)
I'm worried about introducing crashes
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.