Skip to content

Commit

Permalink
Make a distinct warning class for 'recommended hash routine not found'
Browse files Browse the repository at this point in the history
  • Loading branch information
inducer committed Aug 23, 2024
1 parent 0c65d61 commit 6c1bd3f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pytools/persistent_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,18 @@
from warnings import warn


class RecommendedHashNotFoundWarning(UserWarning):
pass


try:
from siphash24 import siphash13 as _default_hash
except ImportError:
warn("Unable to import recommended hash 'siphash24.siphash13', "
"falling back to 'hashlib.sha256'. "
"Run 'python3 -m pip install siphash24' to install "
"the recommended hash.",
stacklevel=1)
RecommendedHashNotFoundWarning, stacklevel=1)
from hashlib import sha256 as _default_hash

if TYPE_CHECKING:
Expand Down

0 comments on commit 6c1bd3f

Please sign in to comment.