This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2014年06月14日 20:33 by eric.snow, last changed 2022年04月11日 14:58 by admin.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 31565 | open | slateny, 2022年02月25日 06:39 | |
| Messages (7) | |||
|---|---|---|---|
| msg220578 - (view) | Author: Eric Snow (eric.snow) * (Python committer) | Date: 2014年06月14日 20:33 | |
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__ [2] https://docs.python.org/3/reference/import.html#import-related-module-attributes |
|||
| msg407721 - (view) | Author: Irit Katriel (iritkatriel) * (Python committer) | Date: 2021年12月05日 17:43 | |
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__" ? |
|||
| msg407866 - (view) | Author: Brett Cannon (brett.cannon) * (Python committer) | Date: 2021年12月06日 21:37 | |
> "Ultimately, the loader set the values of __file__ and/or __cached__" Change it to "sets" and +1 from me! |
|||
| msg407885 - (view) | Author: Eric Snow (eric.snow) * (Python committer) | Date: 2021年12月07日 00:49 | |
The key point is that loaders should be using the spec, not any of the module attrs (like `__file__` and `__cached__`), nor setting them. For the specific paragraph I referenced, it would look more like: It is also appropriate to set __cached__ when __file__ is not set. However, that scenario is quite atypical. Ultimately, __file__ and __cached__ are set by the import system from the module spec provided by the finder. The spec instructs the loader. If a loader can load from a cached module but otherwise does not load from a file, that atypical scenario may be appropriate. |
|||
| msg414159 - (view) | Author: Vidhya (vidhya) * | Date: 2022年02月27日 15:51 | |
If this is still open, I would like to work on this. Please let me know. |
|||
| msg414160 - (view) | Author: Alex Waygood (AlexWaygood) * (Python triager) | Date: 2022年02月27日 16:29 | |
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. |
|||
| msg414207 - (view) | Author: Vidhya (vidhya) * | Date: 2022年02月28日 16:26 | |
Thanks Alex. I will look into @slateny's patch. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:04 | admin | set | github: 65960 |
| 2022年02月28日 16:26:50 | vidhya | set | messages: + msg414207 |
| 2022年02月27日 16:29:07 | AlexWaygood | set | nosy:
+ AlexWaygood messages: + msg414160 |
| 2022年02月27日 15:51:01 | vidhya | set | nosy:
+ vidhya messages: + msg414159 |
| 2022年02月25日 06:39:03 | slateny | set | keywords:
+ patch nosy: + slateny pull_requests: + pull_request29687 stage: needs patch -> patch review |
| 2021年12月07日 00:49:59 | eric.snow | set | messages: + msg407885 |
| 2021年12月06日 22:01:31 | iritkatriel | set | keywords: + easy |
| 2021年12月06日 21:37:42 | brett.cannon | set | messages: + msg407866 |
| 2021年12月05日 17:43:07 | iritkatriel | set | nosy:
+ iritkatriel title: language reference describes the role of module.__file__ inaccurately -> [doc] language reference describes the role of module.__file__ inaccurately messages: + msg407721 versions: + Python 3.9, Python 3.10, Python 3.11, - Python 3.4, Python 3.5 |
| 2014年06月14日 20:35:11 | eric.snow | set | assignee: docs@python nosy: + docs@python components: + Documentation stage: needs patch |
| 2014年06月14日 20:33:24 | eric.snow | create | |