> What's up with that? So far, they all seem to involve the encodings > directory ... Python/codecs.c holds search functions in _PyCodec_SearchPath, among them encodings.__init__.search_function. It also imports "encodings" the first time somebody invokes .encode/.decode on some kind of string, but doesn't hold onto the module. When the last reference to encodings.__init__ goes away, Python will clear all globals - but codecs still holds a reference to search_function, so that won't go away. Invoking search_function later will cause the problem you see. One solution would be to bind all globals used inside encodings.__init__.search_function to the search_function, e.g. by means of a class: class GlobalSearchFunction: _cache = _unknown = class CodecRegistryError(...): def search_function(self,encoding): codecs.register(GlobalSearchFunction().search_function) Of course, if this gets cleaned from sys.modules, nobody will be able to catch CodecRegistryError anymore (since re-importing the module will produce a different class). Regards, Martin
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4