Skip to content
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

Updates for Python 3.13 #1686

Merged
merged 19 commits into from
Oct 28, 2024
Merged

Updates for Python 3.13 #1686

merged 19 commits into from
Oct 28, 2024

Conversation

t-kalinowski
Copy link
Member

@t-kalinowski t-kalinowski commented Oct 23, 2024

For Reticulate internals, Python 3.13 introduces two significant changes:

  1. PyObject_HasAttrString() now emits a non-suppressible warning to stderr when it returns a false value:

    Exception ignored in PyObject_HasAttrString();
    consider using PyObject_HasAttrStringWithError(),
    PyObject_GetOptionalAttrString(), or PyObject_GetAttrString()
    

To prevent this output from repeatedly appearing in user consoles, Reticulate internals have been refactored to use the new C entry points introduced in Python 3.13: PyObject_HasAttrStringWithError and PyObject_GetOptionalAttrString, with backports implemented in reticulate for older Python versions.

  1. Quoting from the Python 3.13 release notes:

    Support for chained classmethod descriptors has been removed. These descriptors can no longer wrap other descriptors, such as property, due to design flaws that led to several issues.

This change affects how the S3 class attribute vector is determined when presenting a Python object at the R level. Specifically, Python classes using metaclasses where __module__ or __name__ is a property can no longer resolve correctly. This issue is encountered in objects subclassing wrapt.ProxyObject and likely other classes using a similar pattern. Consequently, internal updates to get_r_class() in Reticulate were needed, and the S3 class of such objects has now changed.

@t-kalinowski t-kalinowski marked this pull request as ready for review October 24, 2024 17:45
Python 3.13 introduces new stable API C symbols:
- PyObject_HasAttrStringWithError
- PyObject_GetOptionalAttrString

Under normal circumstances we would continue to use the previous API, but unfortunalty, other changes force our hand. The previous PyObject_HasAttrString now issues unsilencable warning to stderr evertime the returned value is 0. So we can no longer use PyObject_HasAttrString without leaking verbose unactionable output to user's consoles.
@t-kalinowski t-kalinowski merged commit 24bc921 into main Oct 28, 2024
16 checks passed
@t-kalinowski t-kalinowski deleted the python-3-13-compat branch October 28, 2024 18:25
@t-kalinowski t-kalinowski restored the python-3-13-compat branch October 28, 2024 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant