[Python-Dev] regrtest.py mystery (original) (raw)

M.-A. Lemburg mal@lemburg.com
Mon, 17 Dec 2001 11:56:14 +0100


"Martin v. Loewis" wrote:

> > Python/codecs.c holds search functions in PyCodecSearchPath, among > > them encodings.init.searchfunction. It also imports "encodings" > > the first time somebody invokes .encode/.decode on some kind of > > string, but doesn't hold onto the module. > > Perhaps it should hold onto the module as well? That would avoid it > getting cleaned up before possibly dependent modules. Re-importing encodings would still do funny things, then: It would register itself once more, resulting in two search functions being registered. codecs would hold one of the encodings modules, but not the other. So if the second search function is ever invoked, you get the same error.

Rather than "fixing" the encodings package, I'd rather suggest to fix the unload procedure in the test suite. Some modules simply should not be unloaded because it is known that the interpreter needs them for internal purposes. In the case of the encodings package it is not only the search function that gets kept alive, it's also the codecs themselves which are cached by the implementation in _codecs.c.

How about following Fred's suggestion to run each test in a separate process (possibly as an option to regrtest.py) ?!

-- Marc-Andre Lemburg CEO eGenix.com Software GmbH


Company & Consulting: http://www.egenix.com/ Python Software: http://www.egenix.com/files/python/