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 2012年06月10日 09:30 by Robin.Schreiber, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| PyState_add-remove_module.patch | Robin.Schreiber, 2012年06月10日 09:30 | |||
| PyState_add-remove_module_v2.patch | Robin.Schreiber, 2012年06月18日 18:59 | |||
| Messages (5) | |||
|---|---|---|---|
| msg162581 - (view) | Author: Robin Schreiber (Robin.Schreiber) * (Python triager) | Date: 2012年06月10日 09:30 | |
PEP 3121 suggests a new way of Module-initialization, where the module state is being wrapped inside a dedicate struct, which can be accessed at runtime via the PyState_FindModule method. For code outside the Init-method, there is no other way to receive the module-state, as it has no reference to the object created by PyModule_Create. PyState_FindModule requires, that the module-state has been attached to the interpreter-state beforehand. Inside an extension module code this is almost everywhere the case except inside the Init-method, because currently _PyState_AddModule is only called by the importer AFTER the extension module has been initialized successfully. As most of the macro definitions inside an extension module, which rely on data stored in the module state, have to receive the state via FindModule, they fail to work inside the modules Init-method. This patch suggests an extension of PyState comprising two publicly available methods (PyState_AddModule, PyState_RemoveModule) that can be called from inside the Init-method, so that the module-state is attached to the interpreter state before further initialization of the module continues. As a result, PyState_FindModule will also work in this region of the extension module and the bespoken expanded macros will also work flawlessly when executed inside the Init code. This patch is especially important for the future application of PEP 3121 together with PEP 384, as the newly created heap-types now reside inside the module-state. As type-objects are frequently used in macro-definitions which are also expanded within the Init-method of a module (or inside a function called from Init), the module state has to be received via FindModule. (The alternative would be nasty redefinitions of the specific macros, shortly before Init) |
|||
| msg162792 - (view) | Author: Martin v. Löwis (loewis) * (Python committer) | Date: 2012年06月14日 14:12 | |
These functions need to be documented. |
|||
| msg163115 - (view) | Author: Robin Schreiber (Robin.Schreiber) * (Python triager) | Date: 2012年06月18日 18:59 | |
Added missing documentation. Also added documentation of PyState_FindModule() which still happened to be missing. |
|||
| msg163392 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2012年06月22日 10:21 | |
New changeset 55e8cba34b11 by Martin v. Löwis in branch 'default': Issue #15042: Add PyState_AddModule and PyState_RemoveModule. http://hg.python.org/cpython/rev/55e8cba34b11 |
|||
| msg163667 - (view) | Author: Martin v. Löwis (loewis) * (Python committer) | Date: 2012年06月23日 20:34 | |
Thanks for the patch! |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:31 | admin | set | github: 59247 |
| 2012年06月23日 20:34:59 | loewis | set | status: open -> closed resolution: fixed messages: + msg163667 |
| 2012年06月22日 10:21:26 | python-dev | set | nosy:
+ python-dev messages: + msg163392 |
| 2012年06月18日 18:59:52 | Robin.Schreiber | set | files:
+ PyState_add-remove_module_v2.patch messages: + msg163115 |
| 2012年06月14日 14:12:18 | loewis | set | nosy:
+ loewis messages: + msg162792 |
| 2012年06月10日 09:30:21 | Robin.Schreiber | create | |