Skip to content

Commit

Permalink
write need bytes object on python 3 (ansible#35143)
Browse files Browse the repository at this point in the history
Otherwise, it fail with:

    Traceback (most recent call last):
      File \"/tmp/ansible_c1zmq3i9/ansible_module_openssl_certificate.py\", line 808, in <module>
        main()
      File \"/tmp/ansible_c1zmq3i9/ansible_module_openssl_certificate.py\", line 787, in main
        certificate.generate(module)
      File \"/tmp/ansible_c1zmq3i9/ansible_module_openssl_certificate.py\", line 692, in generate
        certfile.write(str(crt))
    TypeError: a bytes-like object is required, not 'str'
  • Loading branch information
mscherer authored and ansibot committed Jan 21, 2018
1 parent f23f277 commit 347b5d1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ansible/modules/crypto/openssl_certificate.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ def generate(self, module):
self.challenge_path),
check_rc=True)[1]
with open(self.path, 'wb') as certfile:
certfile.write(str(crt))
certfile.write(to_bytes(crt))
except OSError as exc:
raise CertificateError(exc)

Expand Down

0 comments on commit 347b5d1

Please sign in to comment.