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

Fix #544: Port to Python 3.14 #545

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

vstinner
Copy link

@vstinner vstinner commented Dec 4, 2024

@vstinner
Copy link
Author

vstinner commented Dec 4, 2024

_getattribute() API changed in Python 3.14: see python/cpython@1bb955a.

* _getattribute() API changed in Python 3.14.
* itertools.count() no longer supports pickle on Python 3.14:
  https://docs.python.org/dev/whatsnew/3.14.html#itertools
* Fix annotations test.
@vstinner vstinner changed the title Port to Python 3.14 Fix #544: Port to Python 3.14 Dec 4, 2024
@vstinner
Copy link
Author

vstinner commented Dec 4, 2024

I didn't add py314 to tox.ini since Python 3.14 is only at alpha1 stage, it might be early to add it to tox. Tell me if you want me to add it.

@serhiy-storchaka
Copy link

Why simply not add the own implementation of _getatribute()?

@vstinner
Copy link
Author

vstinner commented Dec 5, 2024

Why simply not add the own implementation of _getatribute()?

Python 3.13:

def _getattribute(obj, name):
    top = obj    
    for subpath in name.split('.'):
        if subpath == '<locals>':
            raise AttributeError("Can't get local attribute {!r} on {!r}"
                                 .format(name, top))
        try:
            parent = obj
            obj = getattr(obj, subpath)
        except AttributeError:
            raise AttributeError("Can't get attribute {!r} on {!r}"
                                 .format(name, top)) from None
    return obj, parent

Python 3.14:

def _getattribute(obj, dotted_path):
    for subpath in dotted_path:
        obj = getattr(obj, subpath)
    return obj

I don't know which implementation is the best, I don't know the cloudpickle project, so I prefer to continue calling what's available in pickle.

At least, I can say that Python 3.14 implementation is the simplest :-)

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.

2 participants