New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[doc] language reference describes the role of module.__file__ inaccurately #65960
Comments
The language reference [1] says: Ultimately, the loader is what makes use of __file__ and/or __cached__ This implies that loaders should use __file__ and __cached__ when loading a module. Instead loaders are meant to implement exec_module() and use the spec that's passed in. The entire section should have a clear note that loaders are not meant to rely a module's import-related attributes. [1] https://docs.python.org/3/reference/import.html#__file__ |
Would it suffice to change "Ultimately, the loader is what makes use of __file__ and/or __cached__" to "Ultimately, the loader set the values of __file__ and/or __cached__" ? |
Change it to "sets" and +1 from me! |
The key point is that loaders should be using the spec, not any of the module attrs (like For the specific paragraph I referenced, it would look more like: It is also appropriate to set __cached__ when __file__ is not set. |
If this is still open, I would like to work on this. Please let me know. |
Hi Vidhya — @slateny submitted a PR for this issue only two days ago (you can see that it's linked to this BPO issue in the "Pull Requests" field). I think it would be good to wait until that has been reviewed before doing any work on a possible PR for this issue :) If you'd like to help out with this issue, you'd of course be very welcome to submit a review for @slateny's patch. |
Thanks Alex. I will look into @slateny's patch. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: