From 98e25b6c8dcde7b4c7e9704f50d72e631e64745c Mon Sep 17 00:00:00 2001 From: tb Date: Fri, 29 Apr 2022 03:34:57 +0000 Subject: [PATCH] Python 3.10: unbreak _hashlib build The build was broken in the update to 3.10.2 due to the upstream commit https://github.com/python/cpython/commit/3ce6945f5f434806eea700eb5ff1bed6d39395e1 This seems to have escaped notice of the maintainers because the build system only whines and carries on instead of failing (although this was also visible in the PLIST). Avoid use of undefined short names and NIDs and do not use an inexistent flag. ok sthen --- lang/python/3.10/Makefile | 2 +- .../3.10/patches/patch-Modules__hashopenssl_c | 32 +++++++++++++++++++ lang/python/3.10/pkg/PLIST-main | 1 + 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/lang/python/3.10/Makefile b/lang/python/3.10/Makefile index d9f12bc46b0..999a01d7831 100644 --- a/lang/python/3.10/Makefile +++ b/lang/python/3.10/Makefile @@ -8,6 +8,6 @@ SHARED_LIBS = python3.10 0.0 VERSION_SPEC = >=3.10,<3.11 PORTROACH = limit:^3\.10 -REVISION = 0 +REVISION = 1 .include diff --git a/lang/python/3.10/patches/patch-Modules__hashopenssl_c b/lang/python/3.10/patches/patch-Modules__hashopenssl_c index 2ca469a2bf0..a0102d005e3 100644 --- a/lang/python/3.10/patches/patch-Modules__hashopenssl_c +++ b/lang/python/3.10/patches/patch-Modules__hashopenssl_c @@ -13,3 +13,35 @@ Index: Modules/_hashopenssl.c #if OPENSSL_VERSION_NUMBER >= 0x30000000L #define PY_EVP_MD EVP_MD #define PY_EVP_MD_fetch(algorithm, properties) EVP_MD_fetch(NULL, algorithm, properties) +@@ -119,6 +114,7 @@ static const py_hashentry_t py_hashes[] = { + PY_HASH_ENTRY(Py_hash_sha256, "SHA256", SN_sha256, NID_sha256), + PY_HASH_ENTRY(Py_hash_sha384, "SHA384", SN_sha384, NID_sha384), + PY_HASH_ENTRY(Py_hash_sha512, "SHA512", SN_sha512, NID_sha512), ++#if !defined(LIBRESSL_VERSION_NUMBER) + /* truncated sha2 */ + PY_HASH_ENTRY(Py_hash_sha512_224, "SHA512_224", SN_sha512_224, NID_sha512_224), + PY_HASH_ENTRY(Py_hash_sha512_256, "SHA512_256", SN_sha512_256, NID_sha512_256), +@@ -133,6 +129,7 @@ static const py_hashentry_t py_hashes[] = { + /* blake2 digest */ + PY_HASH_ENTRY(Py_hash_blake2s, "blake2s256", SN_blake2s256, NID_blake2s256), + PY_HASH_ENTRY(Py_hash_blake2b, "blake2b512", SN_blake2b512, NID_blake2b512), ++#endif + PY_HASH_ENTRY(NULL, NULL, NULL, 0), + }; + +@@ -873,11 +870,15 @@ py_evp_fromname(PyObject *module, const char *digestna + goto exit; + } + ++#if defined(LIBRESSL_VERSION_NUMBER) ++ type = get_hashlib_state(module)->EVPtype; ++#else + if ((EVP_MD_flags(digest) & EVP_MD_FLAG_XOF) == EVP_MD_FLAG_XOF) { + type = get_hashlib_state(module)->EVPXOFtype; + } else { + type = get_hashlib_state(module)->EVPtype; + } ++#endif + + self = newEVPobject(type); + if (self == NULL) { diff --git a/lang/python/3.10/pkg/PLIST-main b/lang/python/3.10/pkg/PLIST-main index 09cdd246cdc..13d5a126bd0 100644 --- a/lang/python/3.10/pkg/PLIST-main +++ b/lang/python/3.10/pkg/PLIST-main @@ -2031,6 +2031,7 @@ lib/python3.10/lib-dynload/ @so lib/python3.10/lib-dynload/_dbm.cpython-310.so @so lib/python3.10/lib-dynload/_decimal.cpython-310.so @so lib/python3.10/lib-dynload/_elementtree.cpython-310.so +@so lib/python3.10/lib-dynload/_hashlib.cpython-310.so @so lib/python3.10/lib-dynload/_heapq.cpython-310.so @so lib/python3.10/lib-dynload/_json.cpython-310.so @so lib/python3.10/lib-dynload/_lsprof.cpython-310.so