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

Workaround for zipimporter not having exec_module before Python 3.10 #1069

Merged
merged 1 commit into from Dec 9, 2022

Conversation

georgevreilly
Copy link
Contributor

Fixes #849

Tested with Python 3.8 and 3.9

else:
# This can happen before Python 3.10
# if spec.loader is a zipimporter and the Python runtime is in a zipfile
code = spec.loader.get_code(module.__name__)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This, in essence, is what loader.exec_module does.

@georgevreilly-stripe
Copy link

@serhii73, can I get this reviewed and merged, please?

Copy link
Member

@Gallaecio Gallaecio left a comment

Choose a reason for hiding this comment

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

Looks good to me, though I wonder if we should go with a try-except approach instead.

@Gallaecio Gallaecio merged commit 9b6c15a into scrapinghub:master Dec 9, 2022
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.

DateParser throws error when imported on embedded Python.
5 participants