Skip to content

Commit fe0e921

Browse files
authored
gh-131876: Revert "gh-131876: extract _hashlib helpers into a separate directory (#136995) (#137307)
Revert "gh-131876: extract `_hashlib` helpers into a separate directory (#136995)" This reverts commit 45138d3.
1 parent e7b55f5 commit fe0e921

20 files changed

+221
-346
lines changed

Makefile.pre.in

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,6 @@ ENSUREPIP= @ENSUREPIP@
227227
# Internal static libraries
228228
LIBMPDEC_A= Modules/_decimal/libmpdec/libmpdec.a
229229
LIBEXPAT_A= Modules/expat/libexpat.a
230-
LIBHASHLIB_INTERNAL_A=Modules/_hashlib/libhashlib.a
231230

232231
# HACL* build configuration
233232
LIBHACL_CFLAGS=@LIBHACL_CFLAGS@
@@ -762,17 +761,6 @@ LIBHACL_HMAC_HEADERS= \
762761
$(LIBHACL_BLAKE2_HEADERS) \
763762
$(LIBHACL_HEADERS)
764763

765-
##########################################################################
766-
# Internal library for cryptographic primitives
767-
768-
LIBHASHLIB_INTERNAL_OBJS= \
769-
Modules/_hashlib/hashlib_buffer.o
770-
771-
LIBHASHLIB_INTERNAL_HEADERS= \
772-
Modules/_hashlib/hashlib_buffer.h \
773-
Modules/_hashlib/hashlib_fetch.h \
774-
Modules/_hashlib/hashlib_mutex.h
775-
776764
#########################################################################
777765
# Rules
778766

@@ -1527,17 +1515,6 @@ $(LIBEXPAT_A): $(LIBEXPAT_OBJS)
15271515
-rm -f $@
15281516
$(AR) $(ARFLAGS) $@ $(LIBEXPAT_OBJS)
15291517

1530-
##########################################################################
1531-
# '_hashlib', '_hmac' and HACL*-based modules helpers
1532-
LIBHASHLIB_INTERNAL_CFLAGS=@LIBHASHLIB_INTERNAL_CFLAGS@ $(PY_STDMODULE_CFLAGS) $(CCSHARED)
1533-
1534-
Modules/_hashlib/hashlib_buffer.o: Modules/_hashlib/hashlib_buffer.c $(LIBHASHLIB_INTERNAL_HEADERS) $(PYTHON_HEADERS)
1535-
$(CC) -I$(srcdir)/Modules/_hashlib -c $(LIBHASHLIB_INTERNAL_CFLAGS) -o $@ $(srcdir)/Modules/_hashlib/hashlib_buffer.c
1536-
1537-
$(LIBHASHLIB_INTERNAL_A): $(LIBHASHLIB_INTERNAL_OBJS)
1538-
-rm -f $@
1539-
$(AR) $(ARFLAGS) $@ $(LIBHASHLIB_INTERNAL_OBJS)
1540-
15411518
##########################################################################
15421519
# HACL* library build
15431520
#
@@ -3380,21 +3357,21 @@ MODULE__CTYPES_TEST_DEPS=$(srcdir)/Modules/_ctypes/_ctypes_test_generated.c.h
33803357
MODULE__CTYPES_MALLOC_CLOSURE=@MODULE__CTYPES_MALLOC_CLOSURE@
33813358
MODULE__DECIMAL_DEPS=$(srcdir)/Modules/_decimal/docstrings.h @LIBMPDEC_INTERNAL@
33823359
MODULE__ELEMENTTREE_DEPS=$(srcdir)/Modules/pyexpat.c @LIBEXPAT_INTERNAL@
3383-
MODULE__HASHLIB_DEPS=@LIBHASHLIB_INTERNAL@
3360+
MODULE__HASHLIB_DEPS=$(srcdir)/Modules/hashlib.h
33843361
MODULE__IO_DEPS=$(srcdir)/Modules/_io/_iomodule.h
33853362

33863363
# HACL*-based cryptographic primitives
3387-
MODULE__MD5_DEPS=$(MODULE__HASHLIB_DEPS) $(LIBHACL_MD5_HEADERS) $(LIBHACL_MD5_LIB_@LIBHACL_LDEPS_LIBTYPE@)
3364+
MODULE__MD5_DEPS=$(srcdir)/Modules/hashlib.h $(LIBHACL_MD5_HEADERS) $(LIBHACL_MD5_LIB_@LIBHACL_LDEPS_LIBTYPE@)
33883365
MODULE__MD5_LDEPS=$(LIBHACL_MD5_LIB_@LIBHACL_LDEPS_LIBTYPE@)
3389-
MODULE__SHA1_DEPS=$(MODULE__HASHLIB_DEPS) $(LIBHACL_SHA1_HEADERS) $(LIBHACL_SHA1_LIB_@LIBHACL_LDEPS_LIBTYPE@)
3366+
MODULE__SHA1_DEPS=$(srcdir)/Modules/hashlib.h $(LIBHACL_SHA1_HEADERS) $(LIBHACL_SHA1_LIB_@LIBHACL_LDEPS_LIBTYPE@)
33903367
MODULE__SHA1_LDEPS=$(LIBHACL_SHA1_LIB_@LIBHACL_LDEPS_LIBTYPE@)
3391-
MODULE__SHA2_DEPS=$(MODULE__HASHLIB_DEPS) $(LIBHACL_SHA2_HEADERS) $(LIBHACL_SHA2_LIB_@LIBHACL_LDEPS_LIBTYPE@)
3368+
MODULE__SHA2_DEPS=$(srcdir)/Modules/hashlib.h $(LIBHACL_SHA2_HEADERS) $(LIBHACL_SHA2_LIB_@LIBHACL_LDEPS_LIBTYPE@)
33923369
MODULE__SHA2_LDEPS=$(LIBHACL_SHA2_LIB_@LIBHACL_LDEPS_LIBTYPE@)
3393-
MODULE__SHA3_DEPS=$(MODULE__HASHLIB_DEPS) $(LIBHACL_SHA3_HEADERS) $(LIBHACL_SHA3_LIB_@LIBHACL_LDEPS_LIBTYPE@)
3370+
MODULE__SHA3_DEPS=$(srcdir)/Modules/hashlib.h $(LIBHACL_SHA3_HEADERS) $(LIBHACL_SHA3_LIB_@LIBHACL_LDEPS_LIBTYPE@)
33943371
MODULE__SHA3_LDEPS=$(LIBHACL_SHA3_LIB_@LIBHACL_LDEPS_LIBTYPE@)
3395-
MODULE__BLAKE2_DEPS=$(MODULE__HASHLIB_DEPS) $(LIBHACL_BLAKE2_HEADERS) $(LIBHACL_BLAKE2_LIB_@LIBHACL_LDEPS_LIBTYPE@)
3372+
MODULE__BLAKE2_DEPS=$(srcdir)/Modules/hashlib.h $(LIBHACL_BLAKE2_HEADERS) $(LIBHACL_BLAKE2_LIB_@LIBHACL_LDEPS_LIBTYPE@)
33963373
MODULE__BLAKE2_LDEPS=$(LIBHACL_BLAKE2_LIB_@LIBHACL_LDEPS_LIBTYPE@)
3397-
MODULE__HMAC_DEPS=$(MODULE__HASHLIB_DEPS) $(LIBHACL_HMAC_HEADERS) $(LIBHACL_HMAC_LIB_@LIBHACL_LDEPS_LIBTYPE@)
3374+
MODULE__HMAC_DEPS=$(srcdir)/Modules/hashlib.h $(LIBHACL_HMAC_HEADERS) $(LIBHACL_HMAC_LIB_@LIBHACL_LDEPS_LIBTYPE@)
33983375
MODULE__HMAC_LDEPS=$(LIBHACL_HMAC_LIB_@LIBHACL_LDEPS_LIBTYPE@)
33993376

34003377
MODULE__SOCKET_DEPS=$(srcdir)/Modules/socketmodule.h $(srcdir)/Modules/addrinfo.h $(srcdir)/Modules/getaddrinfo.c $(srcdir)/Modules/getnameinfo.c

Misc/NEWS.d/next/Build/2025-07-22-14-47-45.gh-issue-131876.oaYEEP.rst

Lines changed: 0 additions & 2 deletions
This file was deleted.

Modules/_hashlib/hashlib_buffer.c

Lines changed: 0 additions & 65 deletions
This file was deleted.

Modules/_hashlib/hashlib_buffer.h

Lines changed: 0 additions & 48 deletions
This file was deleted.

Modules/_hashlib/hashlib_fetch.h

Lines changed: 0 additions & 19 deletions
This file was deleted.

Modules/_hashlib/hashlib_mutex.h

Lines changed: 0 additions & 82 deletions
This file was deleted.

Modules/_hashopenssl.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,14 @@
2424

2525
#include "Python.h"
2626
#include "pycore_hashtable.h"
27-
#include "pycore_strhex.h" // _Py_strhex()
28-
#include "pycore_pyatomic_ft_wrappers.h" // FT_ATOMIC_LOAD_PTR_RELAXED
29-
30-
#include "_hashlib/hashlib_buffer.h"
31-
#include "_hashlib/hashlib_fetch.h"
32-
#include "_hashlib/hashlib_mutex.h"
27+
#include "pycore_strhex.h" // _Py_strhex()
28+
#include "pycore_pyatomic_ft_wrappers.h" // FT_ATOMIC_LOAD_PTR_RELAXED
29+
#include "hashlib.h"
3330

3431
/* EVP is the preferred interface to hashing in OpenSSL */
3532
#include <openssl/evp.h>
3633
#include <openssl/hmac.h>
37-
#include <openssl/crypto.h> // FIPS_mode()
34+
#include <openssl/crypto.h> // FIPS_mode()
3835
/* We use the object interface to discover what hashes OpenSSL supports. */
3936
#include <openssl/objects.h>
4037
#include <openssl/err.h>
@@ -535,7 +532,7 @@ raise_unsupported_algorithm_error(_hashlibstate *state, PyObject *digestmod)
535532
{
536533
raise_unsupported_algorithm_impl(
537534
state->unsupported_digestmod_error,
538-
_Py_HASHLIB_UNSUPPORTED_ALGORITHM,
535+
HASHLIB_UNSUPPORTED_ALGORITHM,
539536
digestmod
540537
);
541538
}
@@ -545,7 +542,7 @@ raise_unsupported_str_algorithm_error(_hashlibstate *state, const char *name)
545542
{
546543
raise_unsupported_algorithm_impl(
547544
state->unsupported_digestmod_error,
548-
_Py_HASHLIB_UNSUPPORTED_STR_ALGORITHM,
545+
HASHLIB_UNSUPPORTED_STR_ALGORITHM,
549546
name
550547
);
551548
}

Modules/blake2module.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@
1515
#endif
1616

1717
#include "Python.h"
18-
#include "pycore_moduleobject.h"
19-
#include "pycore_strhex.h" // _Py_strhex()
18+
#include "hashlib.h"
19+
#include "pycore_strhex.h" // _Py_strhex()
2020
#include "pycore_typeobject.h"
21-
22-
#include "_hashlib/hashlib_buffer.h"
23-
#include "_hashlib/hashlib_mutex.h"
21+
#include "pycore_moduleobject.h"
2422

2523
// QUICK CPU AUTODETECTION
2624
//

0 commit comments

Comments
 (0)