Repository navigation
fix(python): read a unary plus and True/False as an __import__ level - #830
Merged
Merged
Conversation
level=+1 and level=True are relative in Python, so they are no longer credited as external. level=False and +0 stay credited, as does level=-1. Follow-up to #828.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Follow-up to #828 (the relative
__import__level fix).level=+1andlevel=Trueare relative in Python but were still credited as the external module, because the level parser only read unsigned numeric text. It now also strips parentheses and a unary plus, and reads exactlyTrue(1) andFalse(0). No other expression is evaluated.Still credited, as before:
level=False,level=+0,level=-1(invalid at runtime, not known to us), and any level that is not a plain literal.Tests: new cases for
+1,+ 2,(+1),Trueas keyword and as the fifth positional argument, plus the ones that stay credited. They fail on main; adapter suite passes (259).