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

fix: import error messages #164

Merged
merged 1 commit into from
Feb 16, 2024

Conversation

charles-cooper
Copy link
Member

@charles-cooper charles-cooper commented Feb 16, 2024

fix import error messages by fixing compliance with the metapath protocol. instead of always returning a module loader which errors out if it can't find a module, return None early (from find_module) if we can't find the module. this lets the system fall back to the system error handling for not-found modules.

What I did

How I did it

try importing a non-existent module with and without this patch. the results should look like:
(unpatched):

>>> import boa
>>> import asdlkfj
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/charles/titanoboa/boa/interpret.py", line 48, in load_module
    raise ImportError(fullname)
ImportError: asdlkfj
>>> from requests import asldkjfasdf
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/charles/titanoboa/boa/interpret.py", line 48, in load_module
    raise ImportError(fullname)
ImportError: requests.asldkjfasdf

(patched):

>>> import boa
>>> import asdlkfj
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'asdlkfj'
>>> from requests import asldkjfasdf
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'asldkjfasdf' from 'requests' (/home/charles/.venvs/boa/lib/python3.11/site-packages/requests/__init__.py)

How to verify it

Description for the changelog

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

fix import error messages by fixing compliance with the metapath
protocol. instead of always returning a module loader which errors out
if it can't find a module, return None early (from find_module) if we
can't find the module. this lets the system fall back to the system
error handling for not-found modules.
@charles-cooper charles-cooper merged commit bec847b into vyperlang:master Feb 16, 2024
6 of 8 checks passed
@charles-cooper charles-cooper deleted the fix/import-errors branch February 16, 2024 13:51
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.

2 participants