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

Replace use of imp with importlib.util #76

Merged
merged 1 commit into from
Apr 30, 2023
Merged

Conversation

cdent
Copy link
Collaborator

@cdent cdent commented Apr 30, 2023

imp is deprecated and will go away in Python 3.12 (which is very soon).

This implementation based on the importlib docs [1] and passes the quite robust tests that are already present for the urlparser module. Unfortunately there's no good way to be 100% certain that this works for all the many ways that Paste can do an import. So this patch is mostly hoping that test coverage is sufficient.

[1] https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly

Fixes #75

@cdent
Copy link
Collaborator Author

cdent commented Apr 30, 2023

This is going to fail in python 2.7, working on a workaround.

@hugovk
Copy link
Contributor

hugovk commented Apr 30, 2023

Looks about right and tests pass with Python 3.11 (except for a cgi DeprecationWarning failing test_cgiapp.py).

I noticed Python 2.7 is still listed in .travis.yml and tox.ini.

Do you still support it? If so, you'll probably also need the old method. (I recommend dropping 2.7.)

@cdent
Copy link
Collaborator Author

cdent commented Apr 30, 2023

I'd love to drop 2.7 but a significant portion of people who still use Paste (which they shouldn't) are stuck in legacy situations.

The plan is to leave the old way in for python2, currently working through some issues with GitHub actions to get automated testing set up ...

@hugovk
Copy link
Contributor

hugovk commented Apr 30, 2023

Heads up that GitHub Actions is removing Python 2.7 in a couple of weeks: actions/runner-images#7401

@cdent
Copy link
Collaborator Author

cdent commented Apr 30, 2023

That's alright, I still need to get the rest of the testing stuff set up anyway. And I have a local machine where I can do 2.7 testing.

imp is deprecated and will go away in Python 3.12 (which is very
soon). The preferred replacement is importlib.

However, importlib is not available in Python 2.7, so we want
to keep both in order to maintain 2.7 some semblance of 2.7
support.

This implementation is based on the importlib docs [1] and passes
the quite robust tests that are already present for the urlparser
module. Unfortunately there's no good way to be 100% certain that
this works for all the many ways that Paste can do an import. So
this patch is mostly hoping that test coverage is sufficient.

[1] https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly

Fixes #75
@cdent cdent force-pushed the cdent/use-importlib branch from e56fa83 to 7f60a6d Compare April 30, 2023 11:29
@cdent cdent merged commit 0af287f into master Apr 30, 2023
@hugovk hugovk mentioned this pull request Apr 30, 2023
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.

Replace deprecated imp module with importlib
2 participants