[Python-checkins] r46886 - in python/trunk: Lib/test/test_zlib.py Misc/ACKS Modules/zlibmodule.c configure configure.in pyconfig.h.in

neal.norwitz python-checkins at python.org
Mon Jun 12 05:33:10 CEST 2006


Author: neal.norwitz
Date: Mon Jun 12 05:33:09 2006
New Revision: 46886

Modified:
   python/trunk/Lib/test/test_zlib.py
   python/trunk/Misc/ACKS
   python/trunk/Modules/zlibmodule.c
   python/trunk/configure
   python/trunk/configure.in
   python/trunk/pyconfig.h.in
Log:
Patch #1503046, Conditional compilation of zlib.(de)compressobj.copy

copy is only in newer versions of zlib.  This should allow zlibmodule
to work with older versions like the Tru64 buildbot.



Modified: python/trunk/Lib/test/test_zlib.py
==============================================================================
--- python/trunk/Lib/test/test_zlib.py	(original)
+++ python/trunk/Lib/test/test_zlib.py	Mon Jun 12 05:33:09 2006
@@ -302,63 +302,65 @@
         dco = zlib.decompressobj()
         self.assertEqual(dco.flush(), "") # Returns nothing
 
-    def test_compresscopy(self):
-        # Test copying a compression object
-        data0 = HAMLET_SCENE
-        data1 = HAMLET_SCENE.swapcase()
-        c0 = zlib.compressobj(zlib.Z_BEST_COMPRESSION)
-        bufs0 = []
-        bufs0.append(c0.compress(data0))
-
-        c1 = c0.copy()
-        bufs1 = bufs0[:]
-
-        bufs0.append(c0.compress(data0))
-        bufs0.append(c0.flush())
-        s0 = ''.join(bufs0)
-
-        bufs1.append(c1.compress(data1))
-        bufs1.append(c1.flush())
-        s1 = ''.join(bufs1)
-
-        self.assertEqual(zlib.decompress(s0),data0+data0)
-        self.assertEqual(zlib.decompress(s1),data0+data1)
-
-    def test_badcompresscopy(self):
-        # Test copying a compression object in an inconsistent state
-        c = zlib.compressobj()
-        c.compress(HAMLET_SCENE)
-        c.flush()
-        self.assertRaises(ValueError, c.copy)
-
-    def test_decompresscopy(self):
-        # Test copying a decompression object
-        data = HAMLET_SCENE
-        comp = zlib.compress(data)
-
-        d0 = zlib.decompressobj()
-        bufs0 = []
-        bufs0.append(d0.decompress(comp[:32]))
-
-        d1 = d0.copy()
-        bufs1 = bufs0[:]
-
-        bufs0.append(d0.decompress(comp[32:]))
-        s0 = ''.join(bufs0)
-
-        bufs1.append(d1.decompress(comp[32:]))
-        s1 = ''.join(bufs1)
-
-        self.assertEqual(s0,s1)
-        self.assertEqual(s0,data)
-
-    def test_baddecompresscopy(self):
-        # Test copying a compression object in an inconsistent state
-        data = zlib.compress(HAMLET_SCENE)
-        d = zlib.decompressobj()
-        d.decompress(data)
-        d.flush()
-        self.assertRaises(ValueError, d.copy)
+    if hasattr(zlib.compressobj(), "copy"):
+        def test_compresscopy(self):
+            # Test copying a compression object
+            data0 = HAMLET_SCENE
+            data1 = HAMLET_SCENE.swapcase()
+            c0 = zlib.compressobj(zlib.Z_BEST_COMPRESSION)
+            bufs0 = []
+            bufs0.append(c0.compress(data0))
+
+            c1 = c0.copy()
+            bufs1 = bufs0[:]
+
+            bufs0.append(c0.compress(data0))
+            bufs0.append(c0.flush())
+            s0 = ''.join(bufs0)
+
+            bufs1.append(c1.compress(data1))
+            bufs1.append(c1.flush())
+            s1 = ''.join(bufs1)
+
+            self.assertEqual(zlib.decompress(s0),data0+data0)
+            self.assertEqual(zlib.decompress(s1),data0+data1)
+
+        def test_badcompresscopy(self):
+            # Test copying a compression object in an inconsistent state
+            c = zlib.compressobj()
+            c.compress(HAMLET_SCENE)
+            c.flush()
+            self.assertRaises(ValueError, c.copy)
+
+    if hasattr(zlib.decompressobj(), "copy"):
+        def test_decompresscopy(self):
+            # Test copying a decompression object
+            data = HAMLET_SCENE
+            comp = zlib.compress(data)
+
+            d0 = zlib.decompressobj()
+            bufs0 = []
+            bufs0.append(d0.decompress(comp[:32]))
+
+            d1 = d0.copy()
+            bufs1 = bufs0[:]
+
+            bufs0.append(d0.decompress(comp[32:]))
+            s0 = ''.join(bufs0)
+
+            bufs1.append(d1.decompress(comp[32:]))
+            s1 = ''.join(bufs1)
+
+            self.assertEqual(s0,s1)
+            self.assertEqual(s0,data)
+
+        def test_baddecompresscopy(self):
+            # Test copying a compression object in an inconsistent state
+            data = zlib.compress(HAMLET_SCENE)
+            d = zlib.decompressobj()
+            d.decompress(data)
+            d.flush()
+            self.assertRaises(ValueError, d.copy)
 
 def genblock(seed, length, step=1024, generator=random):
     """length-byte stream of random data from a seed (in step-byte blocks)."""

Modified: python/trunk/Misc/ACKS
==============================================================================
--- python/trunk/Misc/ACKS	(original)
+++ python/trunk/Misc/ACKS	Mon Jun 12 05:33:09 2006
@@ -24,6 +24,7 @@
 Jason Asbahr
 David Ascher
 Peter Åstrand
+Chris AtLee
 John Aycock
 Donovan Baarda
 Attila Babo

Modified: python/trunk/Modules/zlibmodule.c
==============================================================================
--- python/trunk/Modules/zlibmodule.c	(original)
+++ python/trunk/Modules/zlibmodule.c	Mon Jun 12 05:33:09 2006
@@ -653,6 +653,7 @@
     return RetVal;
 }
 
+#ifdef HAVE_ZLIB_COPY
 PyDoc_STRVAR(comp_copy__doc__,
 "copy() -- Return a copy of the compression object.");
 
@@ -754,6 +755,7 @@
     Py_XDECREF(retval);
     return NULL;
 }
+#endif
 
 PyDoc_STRVAR(decomp_flush__doc__,
 "flush( [length] ) -- Return a string containing any remaining\n"
@@ -827,8 +829,10 @@
                  comp_compress__doc__},
     {"flush", (binaryfunc)PyZlib_flush, METH_VARARGS,
               comp_flush__doc__},
+#ifdef HAVE_ZLIB_COPY
     {"copy",  (PyCFunction)PyZlib_copy, METH_NOARGS,
               comp_copy__doc__},
+#endif
     {NULL, NULL}
 };
 
@@ -838,8 +842,10 @@
                    decomp_decompress__doc__},
     {"flush", (binaryfunc)PyZlib_unflush, METH_VARARGS,
               decomp_flush__doc__},
+#ifdef HAVE_ZLIB_COPY
     {"copy",  (PyCFunction)PyZlib_uncopy, METH_NOARGS,
               decomp_copy__doc__},
+#endif
     {NULL, NULL}
 };
 

Modified: python/trunk/configure
==============================================================================
--- python/trunk/configure	(original)
+++ python/trunk/configure	Mon Jun 12 05:33:09 2006
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.in Revision: 46720 .
+# From configure.in Revision: 46879 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.59 for python 2.5.
 #
@@ -14980,6 +14980,79 @@
 fi
 
 
+echo "$as_me:$LINENO: checking for inflateCopy in -lz" >&5
+echo $ECHO_N "checking for inflateCopy in -lz... $ECHO_C" >&6
+if test "${ac_cv_lib_z_inflateCopy+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lz  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char inflateCopy ();
+int
+main ()
+{
+inflateCopy ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_z_inflateCopy=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_z_inflateCopy=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_z_inflateCopy" >&5
+echo "${ECHO_T}$ac_cv_lib_z_inflateCopy" >&6
+if test $ac_cv_lib_z_inflateCopy = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_ZLIB_COPY 1
+_ACEOF
+
+fi
+
+
 echo "$as_me:$LINENO: checking for hstrerror" >&5
 echo $ECHO_N "checking for hstrerror... $ECHO_C" >&6
 cat >conftest.$ac_ext <<_ACEOF
@@ -22056,10 +22129,9 @@
   # 1. Remove the extension, and $U if already installed.
   ac_i=`echo "$ac_i" |
 	 sed 's/\$U\././;s/\.o$//;s/\.obj$//'`
-  # 2. Prepend LIBOBJDIR.  When used with automake>=1.10 LIBOBJDIR
-  #    will be set to the directory where LIBOBJS objects are built.
-  ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext"
-  ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo'
+  # 2. Add them.
+  ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext"
+  ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo'
 done
 LIBOBJS=$ac_libobjs
 

Modified: python/trunk/configure.in
==============================================================================
--- python/trunk/configure.in	(original)
+++ python/trunk/configure.in	Mon Jun 12 05:33:09 2006
@@ -2351,6 +2351,9 @@
   AC_CHECK_LIB(resolv, inet_aton)
 )
 
+dnl Check if system zlib has *Copy() functions
+AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, Define if the zlib library has inflateCopy))
+
 AC_MSG_CHECKING(for hstrerror)
 AC_TRY_LINK([
 #include "confdefs.h" 

Modified: python/trunk/pyconfig.h.in
==============================================================================
--- python/trunk/pyconfig.h.in	(original)
+++ python/trunk/pyconfig.h.in	Mon Jun 12 05:33:09 2006
@@ -710,6 +710,9 @@
    */
 #undef HAVE_WORKING_TZSET
 
+/* Define if the zlib library has inflateCopy */
+#undef HAVE_ZLIB_COPY
+
 /* Define to 1 if you have the `_getpty' function. */
 #undef HAVE__GETPTY
 


More information about the Python-checkins mailing list