提交 59f42d11 authored 作者: Frederic Bastien's avatar Frederic Bastien

flake8

上级 052588b9
...@@ -186,11 +186,11 @@ def _config_print(thing, buf, print_doc=True): ...@@ -186,11 +186,11 @@ def _config_print(thing, buf, print_doc=True):
def get_config_md5(): def get_config_md5():
""" """
Return a string sha256 of the current config options. hash_from_code uses Return a string sha256 of the current config options. hash_from_code uses
sha256, and not md5. Updated in PR#5916. Function names will be properly sha256, and not md5. Updated in PR#5916. Function names will be properly
updated in future release. updated in future release.
The string should be such that we can safely assume that two different The string should be such that we can safely assume that two different
config setups will lead to two different strings. config setups will lead to two different strings.
We only take into account config options for which `in_c_key` is True. We only take into account config options for which `in_c_key` is True.
""" """
......
...@@ -1229,16 +1229,16 @@ class CLinker(link.Linker): ...@@ -1229,16 +1229,16 @@ class CLinker(link.Linker):
The signature has the following form: The signature has the following form:
{{{ {{{
'CLinker.cmodule_key', compilation args, libraries, 'CLinker.cmodule_key', compilation args, libraries,
header_dirs, numpy ABI version, config md5, header_dirs, numpy ABI version, config hash,
(op0, input_signature0, output_signature0), (op0, input_signature0, output_signature0),
(op1, input_signature1, output_signature1), (op1, input_signature1, output_signature1),
... ...
(opK, input_signatureK, output_signatureK), (opK, input_signatureK, output_signatureK),
}}} }}}
Note that config md5 uses sha256, and not md5. Function names will Note that config hash now uses sha256, and not md5. Function names will
updated in a future release to reflect the use of hashlib.sha256. updated in a future release to reflect the use of hashlib.sha256.
The signature is a tuple, some elements of which are sub-tuples. The signature is a tuple, some elements of which are sub-tuples.
The outer tuple has a brief header, containing the compilation options The outer tuple has a brief header, containing the compilation options
...@@ -1350,7 +1350,7 @@ class CLinker(link.Linker): ...@@ -1350,7 +1350,7 @@ class CLinker(link.Linker):
constant_ids = dict() constant_ids = dict()
op_pos = {} # Apply -> topological position op_pos = {} # Apply -> topological position
# First we put the header, compile_args, library names and config md5 # First we put the header, compile_args, library names and config hash
# into the signature. # into the signature.
sig = ['CLinker.cmodule_key'] # will be cast to tuple on return sig = ['CLinker.cmodule_key'] # will be cast to tuple on return
if compile_args is not None: if compile_args is not None:
......
...@@ -416,10 +416,10 @@ def get_module_hash(src_code, key): ...@@ -416,10 +416,10 @@ def get_module_hash(src_code, key):
to_hash += list(key_element) to_hash += list(key_element)
elif isinstance(key_element, string_types): elif isinstance(key_element, string_types):
if key_element.startswith('md5:'): if key_element.startswith('md5:'):
# This is actually a sha256 hash of the config options. # This is actually a sha256 hash of the config options.
# Ref PR#5916. String and function names will be updated in # Ref PR#5916. String and function names will be updated in
# future release. # future release.
# We can stop here. # We can stop here.
break break
elif (key_element.startswith('NPY_ABI_VERSION=0x') or elif (key_element.startswith('NPY_ABI_VERSION=0x') or
key_element.startswith('c_compiler_str=')): key_element.startswith('c_compiler_str=')):
...@@ -449,7 +449,7 @@ def get_safe_part(key): ...@@ -449,7 +449,7 @@ def get_safe_part(key):
assert version assert version
# Find the hash part, which is using sha256, not md5. # Find the hash part, which is using sha256, not md5.
# Instances of md5 will be replaced in future release. # Instances of md5 will be replaced in future release.
c_link_key = key[1] c_link_key = key[1]
# In case in the future, we don't have an md5 part and we have # In case in the future, we don't have an md5 part and we have
# such stuff in the cache. In that case, we can set None, and the # such stuff in the cache. In that case, we can set None, and the
......
...@@ -20,8 +20,8 @@ def hash_from_ndarray(data): ...@@ -20,8 +20,8 @@ def hash_from_ndarray(data):
# uint32 and int32 of zeros with the same shape and strides. # uint32 and int32 of zeros with the same shape and strides.
# python hash are not strong, so use sha256 (md5 is not # python hash are not strong, so use sha256 (md5 is not
# FIPS compatible). To not have too long of hash, I call it again on # FIPS compatible). To not have too long of hash, I call it again on
# the concatenation of all parts. # the concatenation of all parts.
if not data.flags["C_CONTIGUOUS"]: if not data.flags["C_CONTIGUOUS"]:
# hash_from_code needs a C-contiguous array. # hash_from_code needs a C-contiguous array.
data = np.ascontiguousarray(data) data = np.ascontiguousarray(data)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论