-
-
Notifications
You must be signed in to change notification settings - Fork 791
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[lang]: disallow absolute relative imports #4268
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, i think poke_search_paths is probably dead now. can you check? if so, let's remove it!
vyper/semantics/analysis/module.py
Outdated
@@ -789,11 +789,7 @@ def _add_import( | |||
# load an InterfaceT or ModuleInfo from an import. | |||
# raises FileNotFoundError | |||
def _load_import(self, node: vy_ast.VyperNode, level: int, module_str: str, alias: str) -> Any: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i guess we can fuse load_import_helper right?
# the directory this (currently being analyzed) module is in | ||
self_search_path = Path(self.ast.resolved_path).parent | ||
|
||
with self.input_bundle.search_path( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think for a relative import, we actually need to override the entire search path. can be a context manager, but something along the lines of
try:
self.input_bundle.search_paths = [self_search_path]
self._load_import_helper(...)
finally:
self.input_bundle.search_paths = original_search_paths
otherwise you can break out of the current directory if the search path falls back to some other path (e.g. like /usr/lib/site-packages/foo/bar)
What I did
How I did it
How to verify it
Commit message
Commit message for the final, squashed PR. (Optional, but reviewers will appreciate it! Please see our commit message style guide for what we would ideally like to see in a commit message.)
Description for the changelog
Cute Animal Picture