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 2013年11月22日 16:35 by brett.cannon, last changed 2022年04月11日 14:57 by admin.
| Messages (5) | |||
|---|---|---|---|
| msg204645 - (view) | Author: Eric Snow (eric.snow) * (Python committer) | Date: 2013年11月28日 07:45 | |
I don't recall the specifics of how we'd talked about making use of module specs in pickle. I vaguely remember (or misremember <wink>) something related to saving __main__.__spec__.name in the pickle rather than __main__.__name__. Anyone have anything more concrete than that? I'm willing to work this out but only with a more specific goal relative to the pickle module. |
|||
| msg204648 - (view) | Author: Alyssa Coghlan (ncoghlan) * (Python committer) | Date: 2013年11月28日 10:20 | |
The specific proposal was to use __spec__.name when __name__ == "__main__" to avoid the pickle compatibility issues described in PEP 395 when using the -m switch. runpy has to be updated first, though. |
|||
| msg206427 - (view) | Author: Alyssa Coghlan (ncoghlan) * (Python committer) | Date: 2013年12月17日 12:40 | |
Issue 19700 means that runpy now ensures that __main__.__spec__ is set appropriately when __main__ is executed via the import system. Issue 19946 means that multiprocessing now ensures that __main__ is configured correctly in child processes to reference a properly initialised "fake main" to allow pickle compatibility with classes and functions defined in __main__ outside "if __name__ == '__main__'" guards. The proposal here is that we make the following changes: - runpy will ensure that when __main__ is executed via the import system, it will also be aliased in sys.modules as __spec__.name - if __main__.__spec__ is set, pickle will use __spec__.name rather than __name__ to pickle classes, functions and methods defined in __main__ - multiprocessing is updated appropriately to skip creating __mp_main__ in child processes when __main__.__spec__ is set in the parent process While I still think this is a reasonable idea, I think it qualifies as a new feature, and hence is better postponed to Python 3.5 |
|||
| msg206450 - (view) | Author: Larry Hastings (larry) * (Python committer) | Date: 2013年12月17日 14:39 | |
So far I agree that this should be postponed to 3.5. |
|||
| msg337605 - (view) | Author: Alyssa Coghlan (ncoghlan) * (Python committer) | Date: 2019年03月10日 10:30 | |
Just noting that PEP 499 covers adding modules executed with `-m` to `sys.modules` under their real name in addition to `__main__`. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:54 | admin | set | github: 63901 |
| 2019年03月10日 10:30:22 | ncoghlan | set | messages: + msg337605 |
| 2015年08月07日 03:10:31 | cameron | set | nosy:
+ cameron |
| 2014年01月07日 05:27:47 | eric.snow | unlink | issue18864 dependencies |
| 2013年12月17日 14:39:57 | larry | set | messages: + msg206450 |
| 2013年12月17日 12:41:16 | ncoghlan | set | title: Update pickle to PEP 451 -> Update pickle to take advantage of PEP 451 |
| 2013年12月17日 12:40:56 | ncoghlan | set | versions:
+ Python 3.5, - Python 3.4 nosy: + larry messages: + msg206427 dependencies: + Handle a non-importable __main__ in multiprocessing |
| 2013年11月29日 16:01:49 | brett.cannon | set | dependencies: + Update runpy for PEP 451 |
| 2013年11月28日 10:20:15 | ncoghlan | set | messages: + msg204648 |
| 2013年11月28日 07:45:11 | eric.snow | set | nosy:
+ pitrou, alexandre.vassalotti messages: + msg204645 type: enhancement stage: test needed -> needs patch |
| 2013年11月23日 19:51:28 | Arfrever | set | nosy:
+ Arfrever |
| 2013年11月22日 16:37:23 | brett.cannon | link | issue18864 dependencies |
| 2013年11月22日 16:35:18 | brett.cannon | create | |