mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 19:31:26 -07:00
to_text, to_bytes, and to_native now have surrogate_or_strict error handler (#4630)
On python3, we want to use the surrogateescape error handler if available for filesystem paths and the like. On python2, have to use strict in these circumstances. Use the new error strategy for to_text, to_bytes, and to_native that allows this.
This commit is contained in:
parent
aa0b93a338
commit
45846127c5
2 changed files with 16 additions and 14 deletions
|
@ -483,7 +483,7 @@ def get_remote_head(git_path, module, dest, version, remote, bare):
|
|||
def is_remote_tag(git_path, module, dest, remote, version):
|
||||
cmd = '%s ls-remote %s -t refs/tags/%s' % (git_path, remote, version)
|
||||
(rc, out, err) = module.run_command(cmd, check_rc=True, cwd=dest)
|
||||
if to_bytes(version) in out:
|
||||
if to_bytes(version, errors='surrogate_or_strict') in out:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
@ -513,7 +513,7 @@ def get_tags(git_path, module, dest):
|
|||
def is_remote_branch(git_path, module, dest, remote, version):
|
||||
cmd = '%s ls-remote %s -h refs/heads/%s' % (git_path, remote, version)
|
||||
(rc, out, err) = module.run_command(cmd, check_rc=True, cwd=dest)
|
||||
if to_bytes(version) in out:
|
||||
if to_bytes(version, errors='surrogate_or_strict') in out:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue