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.

Author vstinner
Recipients tarek, vstinner
Date 2011-05-19.20:42:04
SpamBayes Score 2.8090974e-11
Marked as misclassified No
Message-id <1305837725.55.0.659554087396.issue12124@psf.upfronthosting.co.za>
In-reply-to
Content
"python -m test test_packaging test_zipimport" fails with:

======================================================================
FAIL: testAFakeZlib (test.test_zipimport.CompressedZipImportTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/haypo/prog/HG/cpython/Lib/test/test_zipimport.py", line 130, in testAFakeZlib
    self.fail("expected test to raise ImportError")
AssertionError: expected test to raise ImportError

The problem is that the zipimport module keeps a reference to zlib.decompress() which "makes zlib.decompress immortal": see get_decompress_func() in zipimport.c.

Attached patch replaces the borrowed reference by a classic reference to allow to unload zlib.

I don't think that it makes zipimport slower: it calls PyImport_ImportModuleNoBlock("io") and PyObject_GetAttrString(zlib, "decompress") each time instead of just once, but PyImport_ImportModuleNoBlock() is just a lookup in a dict (if the zlib module is not unloaded between two calls to get_data()).
History
Date User Action Args
2011-05-19 20:42:05vstinnersetrecipients: + vstinner, tarek
2011-05-19 20:42:05vstinnersetmessageid: <1305837725.55.0.659554087396.issue12124@psf.upfronthosting.co.za>
2011-05-19 20:42:04vstinnerlinkissue12124 messages
2011-05-19 20:42:04vstinnercreate