mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 05:42:50 +00:00
Fix places where path needs to be bytes on python3
These were discovered on python3 with fetch code that fails on errors. Probably could be provoked with particular sets of arguments to stat as well.
This commit is contained in:
@@ -915,10 +915,18 @@ class AnsibleModule(object):
|
||||
return (uid, gid)
|
||||
|
||||
def find_mount_point(self, path):
|
||||
path = os.path.realpath(os.path.expanduser(os.path.expandvars(path)))
|
||||
while not os.path.ismount(path):
|
||||
path = os.path.dirname(path)
|
||||
return path
|
||||
path_is_bytes = False
|
||||
if isinstance(path, binary_type):
|
||||
path_is_bytes = True
|
||||
|
||||
b_path = os.path.realpath(to_bytes(os.path.expanduser(os.path.expandvars(path)), errors='surrogate_or_strict'))
|
||||
while not os.path.ismount(b_path):
|
||||
b_path = os.path.dirname(b_path)
|
||||
|
||||
if path_is_bytes:
|
||||
return b_path
|
||||
|
||||
return to_text(b_path, errors='surrogate_or_strict')
|
||||
|
||||
def is_special_selinux_path(self, path):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user