Skip to content

Commit 0f1090b

Browse files
Make zlib default in binascii, update news/whatsnew with pr no
1 parent 6bd56d7 commit 0f1090b

File tree

7 files changed

+27
-37
lines changed

7 files changed

+27
-37
lines changed

Doc/whatsnew/3.14.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1314,7 +1314,7 @@ Build changes
13141314
It is still technically possible to build CPython without it for special needs, like bootstrapping.
13151315
Such builds are not supported, but we can accept pull requests to keep them working.
13161316
As an exception, zlib is not required on WASI.
1317-
(Contributed by Stan Ulbrych in :gh:`xxxxxx`.)
1317+
(Contributed by Stan Ulbrych in :gh:`130297`.)
13181318

13191319
.. _whatsnew314-pep761:
13201320

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
Make zlib required to build CPython with the exception of WASI.
2-
(Contributed by Stan Ulbrych in :gh:`xxxxxx`.)
2+
(Contributed by Stan Ulbrych in :gh:`130297`.)

Modules/binascii.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
#include "Python.h"
6161
#include "pycore_long.h" // _PyLong_DigitValue
6262
#include "pycore_strhex.h" // _Py_strhex_bytes_with_sep()
63-
#ifdef USE_ZLIB_CRC32
63+
#ifndef NO_ZLIB_CRC32
6464
# include "zlib.h"
6565
#endif
6666

@@ -616,7 +616,7 @@ binascii_crc_hqx_impl(PyObject *module, Py_buffer *data, unsigned int crc)
616616
return PyLong_FromUnsignedLong(crc);
617617
}
618618

619-
#ifndef USE_ZLIB_CRC32
619+
#ifdef NO_ZLIB_CRC32
620620
/* Crc - 32 BIT ANSI X3.66 CRC checksum files
621621
Also known as: ISO 3307
622622
**********************************************************************|
@@ -749,7 +749,7 @@ internal_crc32(const unsigned char *bin_data, Py_ssize_t len, unsigned int crc)
749749
result = (crc ^ 0xFFFFFFFF);
750750
return result & 0xffffffff;
751751
}
752-
#endif /* USE_ZLIB_CRC32 */
752+
#endif /* NO_ZLIB_CRC32 */
753753

754754
/*[clinic input]
755755
binascii.crc32 -> unsigned_int
@@ -765,9 +765,11 @@ static unsigned int
765765
binascii_crc32_impl(PyObject *module, Py_buffer *data, unsigned int crc)
766766
/*[clinic end generated code: output=52cf59056a78593b input=bbe340bc99d25aa8]*/
767767

768-
#ifdef USE_ZLIB_CRC32
768+
#ifndef NO_ZLIB_CRC32
769769
/* This is the same as zlibmodule.c zlib_crc32_impl. It exists in two
770-
* modules for historical reasons. */
770+
* modules for historical reasons. They should be consolidated in the future
771+
* once WASI supports zlib.
772+
*/
771773
{
772774
/* Releasing the GIL for very small buffers is inefficient
773775
and may lower performance */
@@ -798,7 +800,7 @@ binascii_crc32_impl(PyObject *module, Py_buffer *data, unsigned int crc)
798800
}
799801
return crc & 0xffffffff;
800802
}
801-
#else /* USE_ZLIB_CRC32 */
803+
#else /* NO_ZLIB_CRC32 */
802804
{
803805
const unsigned char *bin_data = data->buf;
804806
Py_ssize_t len = data->len;
@@ -815,7 +817,7 @@ binascii_crc32_impl(PyObject *module, Py_buffer *data, unsigned int crc)
815817
return internal_crc32(bin_data, len, crc);
816818
}
817819
}
818-
#endif /* USE_ZLIB_CRC32 */
820+
#endif /* NO_ZLIB_CRC32 */
819821

820822
/*[clinic input]
821823
binascii.b2a_hex

PCbuild/pythoncore.vcxproj

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -457,9 +457,7 @@
457457
<ClCompile Include="..\Modules\_weakref.c" />
458458
<ClCompile Include="..\Modules\arraymodule.c" />
459459
<ClCompile Include="..\Modules\atexitmodule.c" />
460-
<ClCompile Include="..\Modules\binascii.c">
461-
<PreprocessorDefinitions>USE_ZLIB_CRC32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
462-
</ClCompile>
460+
<ClCompile Include="..\Modules\binascii.c" />
463461
<ClCompile Include="..\Modules\cmathmodule.c" />
464462
<ClCompile Include="..\Modules\_datetimemodule.c" />
465463
<ClCompile Include="..\Modules\errnomodule.c" />

configure

Lines changed: 7 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5325,9 +5325,6 @@ fi
53255325
dnl Check for compression libraries
53265326
AH_TEMPLATE([HAVE_ZLIB_COPY], [Define if the zlib library has inflateCopy; zlib 1.2.0 (2003) added inflateCopy.])
53275327

5328-
dnl detect zlib from Emscripten emport
5329-
PY_CHECK_EMSCRIPTEN_PORT([ZLIB], [-sUSE_ZLIB])
5330-
53315328
PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0], [
53325329
have_zlib=yes
53335330
dnl zlib 1.2.0 (2003) added inflateCopy
@@ -5342,15 +5339,17 @@ PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0], [
53425339
AS_VAR_IF([have_zlib], [yes], [
53435340
ZLIB_CFLAGS=${ZLIB_CFLAGS-""}
53445341
ZLIB_LIBS=${ZLIB_LIBS-"-lz"}
5342+
BINASCII_CFLAGS="$ZLIB_CFLAGS"
5343+
BINASCII_LIBS="$ZLIB_LIBS"
53455344
PY_CHECK_LIB([z], [inflateCopy], [AC_DEFINE([HAVE_ZLIB_COPY], [1])])
53465345
])
53475346
])
53485347
])
53495348

5350-
dnl binascii can use zlib for optimized crc32.
5351-
AS_VAR_IF([have_zlib], [yes], [
5352-
BINASCII_CFLAGS="-DUSE_ZLIB_CRC32 $ZLIB_CFLAGS"
5353-
BINASCII_LIBS="$ZLIB_LIBS"
5349+
dnl wasi does not support zlib
5350+
AS_VAR_IF([have_zlib], [no], [
5351+
BINASCII_CFLAGS="-DNO_ZLIB_CRC32"
5352+
BINASCII_LIBS=""
53545353
])
53555354

53565355
dnl detect bzip2 from Emscripten emport

pyconfig.h.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1609,7 +1609,8 @@
16091609
/* Define to 1 if you have the 'writev' function. */
16101610
#undef HAVE_WRITEV
16111611

1612-
/* Define if the zlib library has inflateCopy */
1612+
/* Define if the zlib library has inflateCopy; zlib 1.2.0 (2003) added
1613+
inflateCopy. */
16131614
#undef HAVE_ZLIB_COPY
16141615

16151616
/* Define to 1 if you have the <zlib.h> header file. */

0 commit comments

Comments
 (0)