Python: Add example of top-level module shadowing stdlib (v2)#4693
Merged
codeql-ci merged 3 commits intoNov 27, 2020
Merged
Conversation
Although this test is added under the `wrong` folder, the current results from this CodeQL test is actually correct (compared with the Python interpreter). However, they don't match what the extractor does when invoked with `codeql database create`. Since I deemed it "more than an easy fix" to change the extractor behavior for `codeql database create` to match the real python behavior, and it turned out to be quite a challenge to change the extractor behavior for all tests, I'm just going to make THIS ONE test-case behave like the extractor will with `codeql database create`... This is a first commit, to show how the extractor works with qltest by default. Inspired by the debugging in github#4640
dd47465 to
7e407d4
Compare
Member
Author
|
I accidentally included a change to a file that wasn't supposed to be part of this branch, and force pushed to remove this... |
tausbn
requested changes
Nov 26, 2020
tausbn
left a comment
Contributor
There was a problem hiding this comment.
Nice and clear example of the bad behaviour. 👍
I have made two suggestion with regard to typos, otherwise this looks good to me.
Co-authored-by: Taus <tausbn@github.com>
tausbn
approved these changes
Nov 27, 2020
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.
This PR adds a test-case to show a specific kind of bad module resolution that happens when using
codeql database create, since a locally defined module doesn't take precedence in module resolution. It turned out that we don't invoke the extractor in the same way when running our qltests, and that the way qltests behaves is more correct (compared with Python interpreter). Obvious fixes didn't work:sys.path[0].codeql database create: I naively attempted this, but it turned out to be a much bigger tasks than I am ready to take on right now.So instead I changed the test manually to simulate what the result of
codeql database createis (and even that was tricky). Reboot of #4655, but a bit more clear now that I've figured out what to do.Kind of a bonus test hiding within all of this is the
unique_name, which just shows that we're not able to resolve it properly when it resides in non-package directory... but it's not the essential part I'm trying to tests here, I think I just included it as a safety check.