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

Add Python 3.12 compatibility #14

Merged
merged 7 commits into from
Feb 22, 2024

Conversation

pkludig
Copy link

@pkludig pkludig commented Dec 11, 2023

With Version 3.12, the deprecated PEP302 import hooks were removed, leading to import errors as the _SixMetaPathImporter did no longer work.

This pull request introduces the PEP451 methods find_spec, exec_module and a dummy create_module method to the _SixMetaPathImporter class to recreate the functionality in newer Python versions. The old methods are kept to allow backwards compatibility to python versions < 3.4, which should not work with the new methods. This builds and runs the test-suite with python versions 3.8, 3.11 and 3.12. It also builds with Python 2.7, however, the test suite relies on collections.abc, which was only introduced in Python 3.3, so it is incompatible with older versions.

The new find_spec function uses the importlib.util.spec_from_loader function, which was introduced in Python 3.4, so the import is within the function itself, which avoids incompatibilities with older Python versions, as only Python versions >3.4 should call that method.

I've also changed a few strings to raw strings, as escaping dots in normal strings gives a syntax warning in python 3.12.

@George-D-S George-D-S requested a review from jtc42 January 22, 2024 02:38
@AmeyaVS
Copy link

AmeyaVS commented Feb 22, 2024

Can we get a release supporting Python 3.12?
Currently unable to use the package from PyPI.

@jtc42
Copy link

jtc42 commented Feb 22, 2024

This all looks fine to me though it does remind me that we really need to get the test suite running in GitHub Actions if we're going to keep this fork alive for any amount of time. EDIT: Looks like we did set this up, unsure why it's not running here though, need to check that.

I'll try and get a new release out shortly.

@jtc42 jtc42 changed the title Python 3.12 compatibility Add Python 3.12 compatibility Feb 22, 2024
@jtc42 jtc42 merged commit 7ed7d8c into renalreg:master Feb 22, 2024
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