Move a path being passed around as a byte string to being passed around as a text string. (#17190)

This is enough to get minimal copy module working on python3

We have t omodify dataloader's path_dwim_relative_stack and everything
that calls it to use text paths instead of byte string paths
This commit is contained in:
Toshio Kuratomi 2016-08-22 21:55:30 -07:00 committed by GitHub
commit 313d4b2c9e
12 changed files with 94 additions and 58 deletions

View file

@ -21,6 +21,7 @@ import shelve
from ansible.errors import AnsibleError
from ansible.plugins.lookup import LookupBase
from ansible.utils.unicode import to_bytes, to_unicode
class LookupModule(LookupBase):
@ -29,7 +30,7 @@ class LookupModule(LookupBase):
"""
Read the value of "key" from a shelve file
"""
d = shelve.open(shelve_filename)
d = shelve.open(to_bytes(shelve_filename))
res = d.get(key, None)
d.close()
return res
@ -65,7 +66,7 @@ class LookupModule(LookupBase):
if res is None:
raise AnsibleError("Key %s not found in shelve file %s" % (key, file))
# Convert the value read to string
ret.append(str(res))
ret.append(to_unicode(res))
break
else:
raise AnsibleError("Could not locate shelve file in lookup: %s" % file)