Index: configure.in =================================================================== --- configure.in (revision 46756) +++ configure.in (working copy) @@ -2349,6 +2349,9 @@ AC_CHECK_LIB(resolv, inet_aton) ) +dnl Check if system zlib has *Copy() functions +AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(ZLIB_HAS_COPY, 1, Define if the zlib library has inflateCopy)) + AC_MSG_CHECKING(for hstrerror) AC_TRY_LINK([ #include "confdefs.h" Index: pyconfig.h.in =================================================================== --- pyconfig.h.in (revision 46756) +++ pyconfig.h.in (working copy) @@ -82,6 +82,10 @@ /* Define to 1 if you have the header file. */ #undef HAVE_CURSES_H +/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't. + */ +#undef HAVE_DECL_TZNAME + /* Define to 1 if you have the device macros. */ #undef HAVE_DEVICE_MACROS @@ -760,22 +764,22 @@ /* Define if i>>j for signed int i does not extend the sign bit when i < 0 */ #undef SIGNED_RIGHT_SHIFT_ZERO_FILLS -/* The size of a `double', as computed by sizeof. */ +/* The size of `double', as computed by sizeof. */ #undef SIZEOF_DOUBLE -/* The size of a `float', as computed by sizeof. */ +/* The size of `float', as computed by sizeof. */ #undef SIZEOF_FLOAT -/* The size of a `fpos_t', as computed by sizeof. */ +/* The size of `fpos_t', as computed by sizeof. */ #undef SIZEOF_FPOS_T -/* The size of a `int', as computed by sizeof. */ +/* The size of `int', as computed by sizeof. */ #undef SIZEOF_INT -/* The size of a `long', as computed by sizeof. */ +/* The size of `long', as computed by sizeof. */ #undef SIZEOF_LONG -/* The size of a `long long', as computed by sizeof. */ +/* The size of `long long', as computed by sizeof. */ #undef SIZEOF_LONG_LONG /* The number of bytes in an off_t. */ @@ -784,22 +788,22 @@ /* The number of bytes in a pthread_t. */ #undef SIZEOF_PTHREAD_T -/* The size of a `short', as computed by sizeof. */ +/* The size of `short', as computed by sizeof. */ #undef SIZEOF_SHORT -/* The size of a `size_t', as computed by sizeof. */ +/* The size of `size_t', as computed by sizeof. */ #undef SIZEOF_SIZE_T /* The number of bytes in a time_t. */ #undef SIZEOF_TIME_T -/* The size of a `uintptr_t', as computed by sizeof. */ +/* The size of `uintptr_t', as computed by sizeof. */ #undef SIZEOF_UINTPTR_T -/* The size of a `void *', as computed by sizeof. */ +/* The size of `void *', as computed by sizeof. */ #undef SIZEOF_VOID_P -/* The size of a `wchar_t', as computed by sizeof. */ +/* The size of `wchar_t', as computed by sizeof. */ #undef SIZEOF_WCHAR_T /* Define to 1 if you have the ANSI C header files. */ @@ -872,6 +876,9 @@ #endif #endif +/* Define if the zlib library has inflateCopy */ +#undef ZLIB_HAS_COPY + /* Define to 1 if on AIX 3. System headers sometimes define this. We just want to avoid a redefinition error message. */ @@ -935,7 +942,7 @@ /* Define to `int' if does not define. */ #undef mode_t -/* Define to `long' if does not define. */ +/* Define to `long int' if does not define. */ #undef off_t /* Define to `int' if does not define. */ @@ -944,7 +951,7 @@ /* Define to empty if the keyword does not work. */ #undef signed -/* Define to `unsigned' if does not define. */ +/* Define to `unsigned int' if does not define. */ #undef size_t /* Define to `int' if does not define. */ Index: Lib/test/test_zlib.py =================================================================== --- Lib/test/test_zlib.py (revision 46756) +++ Lib/test/test_zlib.py (working copy) @@ -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)) + 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[:] + c1 = c0.copy() + bufs1 = bufs0[:] - bufs0.append(c0.compress(data0)) - bufs0.append(c0.flush()) - s0 = ''.join(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) + 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) + 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_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) + 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])) + d0 = zlib.decompressobj() + bufs0 = [] + bufs0.append(d0.decompress(comp[:32])) - d1 = d0.copy() - bufs1 = bufs0[:] + d1 = d0.copy() + bufs1 = bufs0[:] - bufs0.append(d0.decompress(comp[32:])) - s0 = ''.join(bufs0) + bufs0.append(d0.decompress(comp[32:])) + s0 = ''.join(bufs0) - bufs1.append(d1.decompress(comp[32:])) - s1 = ''.join(bufs1) + bufs1.append(d1.decompress(comp[32:])) + s1 = ''.join(bufs1) - self.assertEqual(s0,s1) - self.assertEqual(s0,data) + 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 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).""" Index: Modules/zlibmodule.c =================================================================== --- Modules/zlibmodule.c (revision 46757) +++ Modules/zlibmodule.c (working copy) @@ -653,6 +653,7 @@ return RetVal; } +#ifdef ZLIB_HAS_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 ZLIB_HAS_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 ZLIB_HAS_COPY {"copy", (PyCFunction)PyZlib_uncopy, METH_NOARGS, decomp_copy__doc__}, +#endif {NULL, NULL} };