Skip to content

Workaround for zipimporter not having exec_module before Python 3.10#1069

Merged
Gallaecio merged 1 commit intoscrapinghub:masterfrom
georgevreilly:fix-exec-module
Dec 9, 2022
Merged

Workaround for zipimporter not having exec_module before Python 3.10#1069
Gallaecio merged 1 commit intoscrapinghub:masterfrom
georgevreilly:fix-exec-module

Conversation

@georgevreilly
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown

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

Copy link
Copy Markdown
Contributor

@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