[Python-Dev] Problem between deallocation of modules and func_globals (original) (raw)
Josiah Carlson jcarlson at uci.edu
Fri Jan 19 01:37:42 CET 2007
- Previous message: [Python-Dev] Problem between deallocation of modules and func_globals
- Next message: [Python-Dev] Problem between deallocation of modules and func_globals
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"Brett Cannon" <brett at python.org> wrote:
I have discovered an issue relating to funcglobals for functions and the deallocation of the module it is contained within. Let's say you store a reference to the function encodings.searchfunction from the 'encodings' module (this came up in C code, but I don't see why it couldn't happen in Python code). Then you delete the one reference to the module that is stored in sys.modules, leading to its deallocation. That triggers the setting of None to every value in encodings.dict. [snip] Anybody have any ideas on how to deal with this short of rewriting some codecs stuff so that they don't depend on global state in the module or just telling me to just live with it?
I would have presumed that keeping a reference to a function should have kept the module "alive". Why? If a function keeps a reference to a module's globals, then even if the module is deleted, the module's dictionary should still persist, because there exists a reference to it, through the reference to the function.
Seems to me like a bug, but the bug could be fixed if the module's dictionary kept a (circular) reference to the module object. Who else has been waiting for a module attribute?
- Josiah
- Previous message: [Python-Dev] Problem between deallocation of modules and func_globals
- Next message: [Python-Dev] Problem between deallocation of modules and func_globals
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]