GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||
GeezerVison is showing github.com — gh-106727: Add `__module__` check for `inspect.getsource(cls)` by gaogaotiantian · Pull Request #106968 · python/cpython Conversation
|
|
This fix is straightforward enough and is a supplement to #106815, so I skipped the news. If @carljm thinks the other way, I can add the news. Also do we want a test for it? It requires some delicate file line number conflict from two files. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Can we add a test that fails without this fix?
This doesn't fix the case I mentioned (metaclass and class using it, both with the same name and in the same module), but it does fix the case where the metaclass is in a different module and the line numbers just happen to collide with another class of the same name.
I'm not seeing a clear way to fix the "metaclass with same name" case, and I'm also not really worried about it.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Oops, this comment crossed with my review. I think skipping news is fine, but I think we should have a test, even though it requires additional files. Subtle cases like this will break again in future refactors if there's no test. If it's worth fixing, it's worth testing. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Fixed the style and added the test case - used a temporary directory for the files so I don't need to add extra files to the source code. Without the new check, the code would've found the first class as the line number of method borrowed from the other module happens to be inside the first class defined in Confirmed that the test would fail without the new check. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Co-authored-by: Carl Meyer <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.