Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 dummycreate_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 versions3.8
,3.11
and3.12
. It also builds with Python2.7
, however, the test suite relies oncollections.abc
, which was only introduced in Python3.3
, so it is incompatible with older versions.The new
find_spec
function uses theimportlib.util.spec_from_loader
function, which was introduced in Python3.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
.