diff options
author | tedder <ted@timmons.me> | 2017-01-03 22:14:20 -0800 |
---|---|---|
committer | Toshio Kuratomi <a.badger@gmail.com> | 2017-01-03 22:14:20 -0800 |
commit | e817b7c391a3b65b3d7fba05abc8695dca55a930 (patch) | |
tree | c33f1f5af38f78e0e17131b0f3529df2a445e31a | |
parent | 62dbe0debb7c115206cf06f50e540237a63c0b9a (diff) | |
download | ansible-modules-core-e817b7c391a3b65b3d7fba05abc8695dca55a930.tar.gz |
git ssh wrapper: py3-compatability with strings
Wrap the fh.write(str) in b() to ensure the string is of the proper type in py2/py3. Otherwise, the following error occurs when using its ssh_wrapper:
An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_8r299r6t/ansible_module_git.py", line 1049, in <module>
main()
File "/tmp/ansible_8r299r6t/ansible_module_git.py", line 928, in main
ssh_wrapper = write_ssh_wrapper()
File "/tmp/ansible_8r299r6t/ansible_module_git.py", line 330, in write_ssh_wrapper
fh.write(template)
TypeError: 'str' does not support the buffer interface
(cherry-picked from 15e12d2cf2f3f1449d1b044fd191f0862e19f557)
-rw-r--r-- | source_control/git.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/source_control/git.py b/source_control/git.py index 7f0fcd86..c3b74057 100644 --- a/source_control/git.py +++ b/source_control/git.py @@ -297,7 +297,7 @@ def write_ssh_wrapper(): except (IOError, OSError): fd, wrapper_path = tempfile.mkstemp() fh = os.fdopen(fd, 'w+b') - template = """#!/bin/sh + template = b("""#!/bin/sh if [ -z "$GIT_SSH_OPTS" ]; then BASEOPTS="" else @@ -309,7 +309,7 @@ if [ -z "$GIT_KEY" ]; then else ssh -i "$GIT_KEY" $BASEOPTS "$@" fi -""" +""") fh.write(template) fh.close() st = os.stat(wrapper_path) |