Skip to content

Conversation

@malder08
Copy link

@malder08 malder08 commented Oct 13, 2025

Update the ModuleImporter class to use find_spec instead of find_module and create_module and exec_module instead of load_module. In Python 3.12, the fallback that looked for a find_module() method if a meta_path entry didn't have a find_spec() method was removed, so the escape hatch didn't work correctly in this version when running with --environment=conda.

@malder08 malder08 force-pushed the malder/update-module-importer branch from e7b37b5 to 3fc7718 Compare October 13, 2025 19:31
@malder08 malder08 marked this pull request as ready for review October 13, 2025 20:42
@malder08 malder08 requested a review from romain-intel October 13, 2025 20:42
raise ImportError(f"No module named '{fullname}'")

# Replace the standard module with the wrapped module in sys.modules
sys.modules[fullname] = wrapped_module
Copy link
Contributor

Choose a reason for hiding this comment

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

Looking at the code of how this is used in the import system, I believe we shouldn't be adding stuff to sys.modules. Maybe we can try to do more in create_module and return wrapped_module there and then not do anything in exec_module. I think exec_module is also for reloading which we do not support much right now.

Copy link
Author

Choose a reason for hiding this comment

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

That makes sense. Originally I was trying not to change the existing logic too much, but I've updated it to have create_module handle everything and it seems much better. Thanks for the help!

@malder08 malder08 force-pushed the malder/update-module-importer branch 2 times, most recently from f70b5a2 to ed9060d Compare October 20, 2025 15:53
@malder08 malder08 requested a review from romain-intel October 20, 2025 16:19
@nflx-mf-bot
Copy link
Collaborator

Netflix internal testing[1388] @ ed9060d

@malder08 malder08 force-pushed the malder/update-module-importer branch from ed9060d to f8ee813 Compare October 21, 2025 22:42
@malder08 malder08 force-pushed the malder/update-module-importer branch from f8ee813 to 05cc612 Compare October 22, 2025 19:42
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.

3 participants