Repository navigation
Conversation
Documentation build overview
466 files changed ·
|
|
This PR is stale because it has been open for 90 days with no activity. |
kushaldas
left a comment
There was a problem hiding this comment.
This breaks the pre-existing promise:
cpython/Lib/test/test_importlib/test_lazy.py
Line 110 in 1d64195
For example if you add the following in Lib/test/test_importlib/test_lazy.py , this passes in the current implementation but fails after applying the patch.
def test_mutated_name_survives_loading(self):
module = self.new_module()
module.__name__ = 'bogus'
# Reading __name__ no longer triggers loading.
self.assertEqual(module.__name__, 'bogus')
# Accessing attr executes TestingImporter's source, which assigns
# __name__ = 'changed'. The earlier user assignment should survive.
self.assertEqual(module.attr, 42)
self.assertEqual(module.__name__, 'bogus'The __name__ assignment should survive the loading.
|
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 |
46b17f7 to
c8188dc
Compare
|
I have made the requested changes; please review again |
|
Thanks for making the requested changes! @kushaldas: please review the changes made to this pull request. |
|
@xuantengh also please rebase the PR for a cleaner merge. |
c8188dc to
6f9f539
Compare
|
Rebased, thanks for the detailed review. I have made the requested changes; please review again |
|
Thanks for making the requested changes! @kushaldas: please review the changes made to this pull request. |
FFY00
left a comment
There was a problem hiding this comment.
Both of these attributes can be overwritten by the module on execution, so we can't just redirect to __spec__.
It seems like this change was motivated by inspect.getframeinfo triggering the import of all lazy modules. IMO this is the wrong approach to solve that issue, inspect should learn about lazy module instead.
|
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 |
|
If the issue reaches a consensus that this is the right approach, feel free to re-open. |
This PR makes
__name__and__file__, as a proxy for_LazyModule.__spec__. That says, reading & writing both will be directly forwarded to_LazyModule.__spec__, which will NOT trigger the lazy loading.