mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-26 06:31:23 -07:00
bytes when passing to os.path.* and opening the file, text at other times
Fixes #15644
This commit is contained in:
parent
f61dd8c7fc
commit
b8a988e922
2 changed files with 6 additions and 5 deletions
|
@ -160,12 +160,13 @@ class DataLoader():
|
|||
if not file_name or not isinstance(file_name, string_types):
|
||||
raise AnsibleParserError("Invalid filename: '%s'" % str(file_name))
|
||||
|
||||
if not self.path_exists(file_name) or not self.is_file(file_name):
|
||||
b_file_name = to_bytes(file_name)
|
||||
if not self.path_exists(b_file_name) or not self.is_file(b_file_name):
|
||||
raise AnsibleFileNotFound("the file_name '%s' does not exist, or is not readable" % file_name)
|
||||
|
||||
show_content = True
|
||||
try:
|
||||
with open(file_name, 'rb') as f:
|
||||
with open(b_file_name, 'rb') as f:
|
||||
data = f.read()
|
||||
if self._vault.is_encrypted(data):
|
||||
data = self._vault.decrypt(data)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue