'find_module' removed in Py3.12; use 'find_spec' instead #1320
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.
Description
Shout out to @dennybiasiolli for pointing out this issue in #1311! 🙏 However, instead of the branching logic that creates separate codepaths for Py3.12 found in that PR, I believe a simpler solution is possible:
Since the
find_spec
impl is backwards compatible withfind_module
and has been available since Py3.4, it should work as a drop-in replacement on all of the Python runtimes Zappa currently supports (Py3.8 - Py3.12), so branching logic shouldn't be necessary.Note: I intentionally kept this PR as small as possible in order to help expedite it, as it's one of the last remaining blockers for our next release that will bring long-awaited support for Py3.12 to Zappa. That said, further improvements can definitely be made to Zappa's aging CLI impl, such as following DRY principles to consolidate the repetitive lines of code seen here. However, IMO, code cleanup is low priority such that it shouldn't block our next release; instead, it can be considered for inclusion during planning for subsequent Zappa release cycles.
Related
Supersedes #1311
Relates to #1291