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

Import hooks should be updated for newer Python versions #5000

Open
vyasr opened this issue Dec 9, 2024 · 1 comment
Open

Import hooks should be updated for newer Python versions #5000

vyasr opened this issue Dec 9, 2024 · 1 comment

Comments

@vyasr
Copy link

vyasr commented Dec 9, 2024

Describe the current behavior
The import hooks in https://github.com/googlecolab/colabtools/tree/main/google/colab/_import_hooks are written for pre-Python 3.4. The find_module method was replaced by find_spec in Python 3.4, at which point find_module was also deprecated. importlib.util.find_spec works around the possibility of old finders by simply ignoring those that lack this method, but this means that the modules that colab is patching will not benefit from newer functionality in importlib or related modules that relies on this function. Moreover, new finder implementations may not be written around this and may expect find_spec to be defined on all loaders in sys.meta_path, resulting in runtime errors. A concrete example of this is in numba-cuda, which uses a custom finder to provide backwards compatibility with the legacy cuda target in numba (see this post for more information).

Describe the expected behavior
Finders should be able to rely on all elements of sys.meta_path implementing find_spec

What web browser you are using
Firefox

Additional context
The issue is reproducible with this gist: https://colab.research.google.com/gist/vyasr/9ef26e1073037a15d08fc847798f39b2/colab_meta_path.ipynb

@colaboratory-team
Copy link
Contributor

Thanks for the report, tracking internally in b/383879146

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants