Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions cfgrib/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,8 +531,11 @@ def from_indexpath_or_filestream(
# Reading and writing the index can be explicitly suppressed by passing indexpath==''.
if not indexpath:
return cls.from_fieldset(filestream, index_keys, computed_keys)

hash = hashlib.md5(repr(index_keys).encode("utf-8")).hexdigest()
repr_index_keys = repr(index_keys).encode("utf-8")
try:
hash = hashlib.md5(repr_index_keys, usedforsecurity=False).hexdigest()
except TypeError:
hash = hashlib.md5(repr_index_keys).hexdigest()
indexpath = indexpath.format(path=filestream.path, hash=hash, short_hash=hash[:5])
try:
with compat_create_exclusive(indexpath) as new_index_file:
Expand Down
Loading