Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Bugs

[issue15042] Implemented PyState_AddModule, PyState_RemoveModule

 

 

Python bugs RSS feed   Index | Next | Previous | View Threaded


report at bugs

Jun 10, 2012, 2:30 AM

Post #1 of 5 (94 views)
Permalink
[issue15042] Implemented PyState_AddModule, PyState_RemoveModule

New submission from Robin Schreiber <robin.schreiber [at] me>:

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)

----------
components: Interpreter Core
files: PyState_add-remove_module.patch
keywords: patch
messages: 162581
nosy: Robin.Schreiber
priority: normal
severity: normal
status: open
title: Implemented PyState_AddModule, PyState_RemoveModule
type: enhancement
versions: Python 3.3
Added file: http://bugs.python.org/file25871/PyState_add-remove_module.patch

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15042>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jun 14, 2012, 7:12 AM

Post #2 of 5 (91 views)
Permalink
[issue15042] Implemented PyState_AddModule, PyState_RemoveModule [In reply to]

Martin v. Löwis <martin [at] v> added the comment:

These functions need to be documented.

----------
nosy: +loewis

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15042>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jun 18, 2012, 11:59 AM

Post #3 of 5 (87 views)
Permalink
[issue15042] Implemented PyState_AddModule, PyState_RemoveModule [In reply to]

Robin Schreiber <robin.schreiber [at] me> added the comment:

Added missing documentation. Also added documentation of PyState_FindModule() which still happened to be missing.

----------
Added file: http://bugs.python.org/file26046/PyState_add-remove_module_v2.patch

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15042>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jun 22, 2012, 3:21 AM

Post #4 of 5 (82 views)
Permalink
[issue15042] Implemented PyState_AddModule, PyState_RemoveModule [In reply to]

Roundup Robot <devnull [at] psf> added the comment:

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

----------
nosy: +python-dev

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15042>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jun 23, 2012, 1:34 PM

Post #5 of 5 (83 views)
Permalink
[issue15042] Implemented PyState_AddModule, PyState_RemoveModule [In reply to]

Martin v. Löwis <martin [at] v> added the comment:

Thanks for the patch!

----------
resolution: -> fixed
status: open -> closed

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15042>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com

Python bugs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.