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月12日 16:24 by lemburg, last changed 2022年04月11日 14:58 by admin.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| FrozenImporter-without-__main__-support.patch | lemburg, 2014年06月12日 16:25 | Patch implementing this idea for Python 3.4.1 | ||
| Messages (2) | |||
|---|---|---|---|
| msg220364 - (view) | Author: Marc-Andre Lemburg (lemburg) * (Python committer) | Date: 2014年06月12日 16:24 | |
The logic in runpy.run_path() assumes that removing the __main__ entry from sys.modules is enough to be able to use the module search logic for e.g. importing packages and ZIP files (with embedded __main__.py files). In Python 3.4 (and probably also 3.3 where the importlib was added), this no longer works if a frozen __main__ module is present. The reason is that the sys.meta_path lists the FrozenImporter before the PathFinder. The runpy trick only works if the PathFinder gets a chance to do its magic, but never gets to play, since the FrozenImporter always returns the existing frozen __main__ module (causing all kinds of strange effects). Now, looking at the implementation, the frozen __main__ is imported by import.c, not the importlib, so a working solution is to not have the FrozenImporter work on __main__ modules at all. This then allows the PathFinder to deal with finding the __main__ module in directories or ZIP files and thus allows the hack in runpy to work again. BTW: In the long run, it would probably better to clean up runpy altogether. It's really messy code due to the many details that it has to address, but I guess this a larger project on its own. |
|||
| msg408353 - (view) | Author: Irit Katriel (iritkatriel) * (Python committer) | Date: 2021年12月12日 00:21 | |
The code looks very different from the patch now, is this issue still relevant? |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:04 | admin | set | status: pending -> open github: 65936 |
| 2021年12月12日 00:21:42 | iritkatriel | set | status: open -> pending nosy: + iritkatriel messages: + msg408353 |
| 2020年03月18日 18:05:17 | brett.cannon | set | nosy:
- brett.cannon |
| 2014年06月12日 16:54:49 | berker.peksag | set | nosy:
+ brett.cannon, ncoghlan, eric.snow |
| 2014年06月12日 16:25:41 | lemburg | set | files:
+ FrozenImporter-without-__main__-support.patch keywords: + patch |
| 2014年06月12日 16:24:20 | lemburg | create | |