gh-141907: Better handle support for SHA3 for test_hashlib#141908
Merged
gpshead merged 2 commits intopython:mainfrom Nov 24, 2025
Merged
gh-141907: Better handle support for SHA3 for test_hashlib#141908gpshead merged 2 commits intopython:mainfrom
gpshead merged 2 commits intopython:mainfrom
Conversation
It's possible that the SSL library supports only SHA3 algo and doesn't have SHAKE one. The current test wrongly detect this and set both HASH and HASHXOF to None expecting to have the extra SHA3 attributes present but this should only be true for SHAKE algo. To better handle this, move the HASH condition to a dedicated try-expect condition and check if HASHXOF is None in the relevant code effectively checking if SHA3 is supported by the SSL library but SHAKE algo needs to use the sha3module one. Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Closed
3 tasks
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
gpshead
approved these changes
Nov 24, 2025
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this pull request
Nov 24, 2025
…honGH-141908) * test_hashlib: better handle support for SHA3 It's possible that the SSL library supports only SHA3 algo and doesn't have SHAKE one. The current test wrongly detect this and set both HASH and HASHXOF to None expecting to have the extra SHA3 attributes present but this should only be true for SHAKE algo. To better handle this, move the HASH condition to a dedicated try-expect condition and check if HASHXOF is None in the relevant code effectively checking if SHA3 is supported by the SSL library but SHAKE algo needs to use the sha3module one. Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> * rework the conditional import for all its attrs --------- (cherry picked from commit fee7782) Co-authored-by: Christian Marangi <ansuelsmth@gmail.com> Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> Co-authored-by: Gregory P. Smith <greg@krypto.org>
|
GH-141918 is a backport of this pull request to the 3.14 branch. |
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this pull request
Nov 24, 2025
…honGH-141908) * test_hashlib: better handle support for SHA3 It's possible that the SSL library supports only SHA3 algo and doesn't have SHAKE one. The current test wrongly detect this and set both HASH and HASHXOF to None expecting to have the extra SHA3 attributes present but this should only be true for SHAKE algo. To better handle this, move the HASH condition to a dedicated try-expect condition and check if HASHXOF is None in the relevant code effectively checking if SHA3 is supported by the SSL library but SHAKE algo needs to use the sha3module one. Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> * rework the conditional import for all its attrs --------- (cherry picked from commit fee7782) Co-authored-by: Christian Marangi <ansuelsmth@gmail.com> Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> Co-authored-by: Gregory P. Smith <greg@krypto.org>
|
GH-141919 is a backport of this pull request to the 3.13 branch. |
picnixz
pushed a commit
that referenced
this pull request
Nov 25, 2025
…-141908) (#141918) gh-141907: Better handle support for SHA3 for test_hashlib (GH-141908) * test_hashlib: better handle support for SHA3 It's possible that the SSL library supports only SHA3 algo and doesn't have SHAKE one. The current test wrongly detect this and set both HASH and HASHXOF to None expecting to have the extra SHA3 attributes present but this should only be true for SHAKE algo. To better handle this, move the HASH condition to a dedicated try-expect condition and check if HASHXOF is None in the relevant code effectively checking if SHA3 is supported by the SSL library but SHAKE algo needs to use the sha3module one. --------- (cherry picked from commit fee7782) Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> Co-authored-by: Christian Marangi <ansuelsmth@gmail.com> Co-authored-by: Gregory P. Smith <greg@krypto.org>
picnixz
pushed a commit
that referenced
this pull request
Nov 25, 2025
…-141908) (#141919) gh-141907: Better handle support for SHA3 for test_hashlib (GH-141908) * test_hashlib: better handle support for SHA3 It's possible that the SSL library supports only SHA3 algo and doesn't have SHAKE one. The current test wrongly detect this and set both HASH and HASHXOF to None expecting to have the extra SHA3 attributes present but this should only be true for SHAKE algo. To better handle this, move the HASH condition to a dedicated try-expect condition and check if HASHXOF is None in the relevant code effectively checking if SHA3 is supported by the SSL library but SHAKE algo needs to use the sha3module one. --------- (cherry picked from commit fee7782) Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> Co-authored-by: Christian Marangi <ansuelsmth@gmail.com> Co-authored-by: Gregory P. Smith <greg@krypto.org>
StanFromIreland
pushed a commit
to StanFromIreland/cpython
that referenced
this pull request
Dec 6, 2025
…honGH-141908) * test_hashlib: better handle support for SHA3 It's possible that the SSL library supports only SHA3 algo and doesn't have SHAKE one. The current test wrongly detect this and set both HASH and HASHXOF to None expecting to have the extra SHA3 attributes present but this should only be true for SHAKE algo. To better handle this, move the HASH condition to a dedicated try-expect condition and check if HASHXOF is None in the relevant code effectively checking if SHA3 is supported by the SSL library but SHAKE algo needs to use the sha3module one. Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> * rework the conditional import for all its attrs --------- Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> Co-authored-by: Gregory P. Smith <greg@krypto.org>
ashm-dev
pushed a commit
to ashm-dev/cpython
that referenced
this pull request
Dec 8, 2025
…honGH-141908) * test_hashlib: better handle support for SHA3 It's possible that the SSL library supports only SHA3 algo and doesn't have SHAKE one. The current test wrongly detect this and set both HASH and HASHXOF to None expecting to have the extra SHA3 attributes present but this should only be true for SHAKE algo. To better handle this, move the HASH condition to a dedicated try-expect condition and check if HASHXOF is None in the relevant code effectively checking if SHA3 is supported by the SSL library but SHAKE algo needs to use the sha3module one. Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> * rework the conditional import for all its attrs --------- Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> Co-authored-by: Gregory P. Smith <greg@krypto.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
It's possible that the SSL library supports only SHA3 algo and doesn't have SHAKE one.
The current test wrongly detect this and set both HASH and HASHXOF to None expecting to have the extra SHA3 attributes present but this should only be true for SHAKE algo.
To better handle this, move the HASH condition to a dedicated try-expect condition and check if HASHXOF is None in the relevant code effectively checking if SHA3 is supported by the SSL library but SHAKE algo needs to use the sha3module one.