[New-bugs-announce] [issue22212] zipfile.py fails if zlib.so module fails to build.

John Malmberg report at bugs.python.org
Sat Aug 16 23:29:12 CEST 2014


New submission from John Malmberg:

If the zlib.so fails to build while building python, subsequent runs of setup.py fail, which prevents a trying again to build zlib.so after the issue is fixed unless all the .so modules built are deleted.

   File "/PRJ_ROOT/CPYTHON/Lib/zipfile.py", line 20, in <module>
     crc32 = zlib.crc32
AttributeError: module 'zlib' has no attribute 'crc32'
make: *** [sharedmods] Error 1


zipfile.py is trying to test for a missing zlib.so by checking if the import fails.

The problem is that while the zlib module did not get built, the import of it succeeds because the directory is now in the module path at this
point in the build.

Using -v on Python shows the import succeeding.

Python 3.5.0a0 (default, Aug 13 2014, 19:13:13) [C] on openvms0
Type "help", "copyright", "credits" or "license" for more information.
 >>> import zlib
# possible namespace for /PRJ_ROOT/CPYTHON/Modules/zlib
import 'zlib' # None.

In order to get setup.py to work in this case, the following patch is
needed for zipfile.py

--- /src_root/cpython/Lib/zipfile.py    Mon Jun 16 18:00:20 2014
+++ /vms_root/cpython/Lib/zipfile.py    Thu Aug 14 20:39:47 2014
@@ -18,7 +18,7 @@
  try:
      import zlib # We may need its compression method
      crc32 = zlib.crc32
-except ImportError:
+except (ImportError, AttributeError):
      zlib = None
      crc32 = binascii.crc32

This is not a complete solution for zlib.so module not building.  The run_tests.py also fails when zlib.so is not present.

Setup.py reports that zlib.so is an optional module, so not being build should not cause the setup.py to fail.

----------
components: Build
messages: 225417
nosy: John.Malmberg
priority: normal
severity: normal
status: open
title: zipfile.py fails if  zlib.so module fails to build.
versions: Python 3.5

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22212>
_______________________________________


More information about the New-bugs-announce mailing list