mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix python3 test.
This commit is contained in:
parent
130139dc80
commit
30f827d92d
2 changed files with 4 additions and 2 deletions
|
@ -310,7 +310,9 @@ class Templar:
|
||||||
return C.DEFAULT_NULL_REPRESENTATION
|
return C.DEFAULT_NULL_REPRESENTATION
|
||||||
|
|
||||||
# Using a cache in order to prevent template calls with already templated variables
|
# Using a cache in order to prevent template calls with already templated variables
|
||||||
sha1_hash = sha1(variable.encode('utf-8') + str(preserve_trailing_newlines) + str(escape_backslashes) + str(fail_on_undefined) + str(overrides)).hexdigest()
|
variable_hash = sha1(text_type(variable).encode('utf-8'))
|
||||||
|
options_hash = sha1((text_type(preserve_trailing_newlines) + text_type(escape_backslashes) + text_type(fail_on_undefined) + text_type(overrides)).encode('utf-8'))
|
||||||
|
sha1_hash = variable_hash.hexdigest() + options_hash.hexdigest()
|
||||||
if sha1_hash in self._cached_result:
|
if sha1_hash in self._cached_result:
|
||||||
result = self._cached_result[sha1_hash]
|
result = self._cached_result[sha1_hash]
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -76,7 +76,7 @@ class HostVars(collections.Mapping):
|
||||||
data = self._variable_manager.get_vars(loader=self._loader, host=host, play=self._play, include_hostvars=False)
|
data = self._variable_manager.get_vars(loader=self._loader, host=host, play=self._play, include_hostvars=False)
|
||||||
|
|
||||||
# Using cache in order to avoid template call
|
# Using cache in order to avoid template call
|
||||||
sha1_hash = sha1(str(data)).hexdigest()
|
sha1_hash = sha1(str(data).encode('utf-8')).hexdigest()
|
||||||
if sha1_hash in self._cached_result:
|
if sha1_hash in self._cached_result:
|
||||||
result = self._cached_result[sha1_hash]
|
result = self._cached_result[sha1_hash]
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue