Changes in imports and one minor fix for globals. #8
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.
Hello,
I made some changes in imports, in order to model the 'from A import B' instructions correctly.
Overview of what changed:
would be translated to(in pseudo code):
Now the same snippet will be translated to:
Note that 'a' could be either a module, a sub-package or something defined in the global scope of the package (at the global scope of the __init__ file).
I created a new instruction PythonImportFromGetInstruction which extends SSAGetInstruction so it shouldn't break anything on your end.
The need to differentiate between the two comes from the fact that an attribute access instruction (modeled as a normal field get instruction) should not be able to read the sub-packages or the modules of a package object if they are not available at the global scope of the packages' __init__ file. When using the "from.. import..." instructions however you also need to be able to access modules and sub-packages not available in the global scope of the __init__ file. For this we added the new instruction.
For the same reason we removed all the additional get instructions and changed the 'from' part to be just like normal imports (contain the whole path to the package/module). This may break something on your part. Another reason for this change is that explicit relative imports where very ugly with multiple get instructions.
It also includes a minor fix for globals in analyzing multiple files.
Thanks,
Sifis.