Repository navigation
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.
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.
It looks like this would just lead to ModuleNotFoundError below, which seems misleading because module does exist. Is ModuleNotFoundError caught somewhere and pyclbr proceeds to next module? Did you test if this change fixes the reported bug?
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.
The change from ValueError to an ImportError (subclass) makes it to be processed reasonable (skip to next) in the caller https://github.com/python/cpython/blob/3.10/Lib/pyclbr.py#L243 /
visit_Import()in the call stack shown by the trace in bpo 43299 (2 levels higher). And solves the bug in that case at least - and similar in other callers of_readmodule()In that case the module (main) can indeed not be found in the filesystem for parsing. regular modules have a spec. Raising an ImportError with extra specific text could be another option.