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

Merged
merged 4 commits into from
Jan 14, 2025
Merged

Fix #544: Port to Python 3.14 #545

merged 4 commits into from
Jan 14, 2025

Conversation

vstinner
Copy link
Contributor

@vstinner vstinner commented Dec 4, 2024

@vstinner
Copy link
Contributor 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
Contributor 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
Contributor 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 :-)

@vstinner
Copy link
Contributor Author

Ping @ogrisel.

@ogrisel
Copy link
Contributor

ogrisel commented Jan 14, 2025

Hum I need to investigate why the CI is no longer running on PRs.

@ogrisel
Copy link
Contributor

ogrisel commented Jan 14, 2025

For some reason, the github actions workflow approval button does no longer show up on the PR itself, but it still shows up in the github actions tab.

Copy link
Contributor

@ogrisel ogrisel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix. I added a 3.14 config to the CI and all tests pass.

@unittest.skipIf(
sys.version_info >= (3, 14),
"itertools.count() doesn't support pickle on Python 3.14+",
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vstinner isn't that considered a regression? Why wouldn't such a simple object not be picklable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ogrisel ogrisel merged commit 7468d72 into cloudpipe:master Jan 14, 2025
25 checks passed
@vstinner vstinner deleted the py314 branch January 14, 2025 14:50
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.

3 participants