Skip to content

Commit da84551

Browse files
committed
bpo-43669: Drop the internal _sha3 module per PEP 644
https://www.python.org/dev/peps/pep-0644/#sha-3
1 parent f528045 commit da84551

32 files changed

+4
-6464
lines changed

.github/CODEOWNERS

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ Python/ast_opt.c @isidentical
2828
**/*md5* @python/crypto-team @tiran
2929
**/*blake* @python/crypto-team @tiran
3030
/Modules/_blake2/** @python/crypto-team @tiran
31-
/Modules/_sha3/** @python/crypto-team @tiran
3231

3332
# logging
3433
**/*logging* @vsajip

Lib/hashlib.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,6 @@ def __get_builtin_constructor(name):
103103
import _blake2
104104
cache['blake2b'] = _blake2.blake2b
105105
cache['blake2s'] = _blake2.blake2s
106-
elif name in {'sha3_224', 'sha3_256', 'sha3_384', 'sha3_512'}:
107-
import _sha3
108-
cache['sha3_224'] = _sha3.sha3_224
109-
cache['sha3_256'] = _sha3.sha3_256
110-
cache['sha3_384'] = _sha3.sha3_384
111-
cache['sha3_512'] = _sha3.sha3_512
112-
elif name in {'shake_128', 'shake_256'}:
113-
import _sha3
114-
cache['shake_128'] = _sha3.shake_128
115-
cache['shake_256'] = _sha3.shake_256
116106
except ImportError:
117107
pass # no extension module, this hash is unsupported.
118108

Lib/test/test_hashlib.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
COMPILED_WITH_PYDEBUG = hasattr(sys, 'gettotalrefcount')
2929

3030
# default builtin hash module
31-
default_builtin_hashes = {'md5', 'sha1', 'sha256', 'sha512', 'sha3', 'blake2'}
31+
default_builtin_hashes = {'md5', 'sha1', 'sha256', 'sha512', 'blake2'}
3232
# --with-builtin-hashlib-hashes override
3333
builtin_hashes = sysconfig.get_config_var("PY_BUILTIN_HASHLIB_HASHES")
3434
if builtin_hashes is None:
@@ -174,15 +174,6 @@ def add_builtin_constructor(name):
174174
add_builtin_constructor('blake2s')
175175
add_builtin_constructor('blake2b')
176176

177-
_sha3 = self._conditional_import_module('_sha3')
178-
if _sha3:
179-
add_builtin_constructor('sha3_224')
180-
add_builtin_constructor('sha3_256')
181-
add_builtin_constructor('sha3_384')
182-
add_builtin_constructor('sha3_512')
183-
add_builtin_constructor('shake_128')
184-
add_builtin_constructor('shake_256')
185-
186177
super(HashLibTestCase, self).__init__(*args, **kwargs)
187178

188179
@property
@@ -407,8 +398,7 @@ def check_blocksize_name(self, name, block_size=0, digest_size=0,
407398
self.assertEqual(len(m.digest()), digest_size)
408399
self.assertEqual(len(m.hexdigest()), 2*digest_size)
409400
self.assertEqual(m.name, name)
410-
# split for sha3_512 / _sha3.sha3 object
411-
self.assertIn(name.split("_")[0], repr(m))
401+
self.assertIn(name, repr(m))
412402

413403
def test_blocksize_name(self):
414404
self.check_blocksize_name('md5', 64, 16)

Makefile.pre.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,6 @@ coverage-lcov:
557557
'*/Modules/_blake2/impl/*' \
558558
'*/Modules/_ctypes/libffi*/*' \
559559
'*/Modules/_decimal/libmpdec/*' \
560-
'*/Modules/_sha3/kcp/*' \
561560
'*/Modules/expat/*' \
562561
'*/Modules/zlib/*' \
563562
'*/Include/*' \
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Drop the internal _sha3 module per PEP 644. Patch by Illia Volochii.

Modules/Setup

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,6 @@ _symtable symtablemodule.c
263263
#_sha1 sha1module.c
264264
#_sha256 sha256module.c -DPy_BUILD_CORE_BUILTIN
265265
#_sha512 sha512module.c -DPy_BUILD_CORE_BUILTIN
266-
#_sha3 _sha3/sha3module.c
267266

268267
# _blake module
269268
#_blake2 _blake2/blake2module.c _blake2/blake2b_impl.c _blake2/blake2s_impl.c

Modules/_sha3/README.txt

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

Modules/_sha3/cleanup.py

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

Modules/_sha3/clinic/sha3module.c.h

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

Modules/_sha3/kcp/KeccakHash.c

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

0 commit comments

Comments
 (0)