Comment 4 for bug 1463373

Revision history for this message
Scott Moser (smoser) wrote : Re: cc_apt_configure does not work with python3

recreates easily enough:

$ python3 -c 'from cloudinit.config.cc_apt_configure import getkeybyid; import sys; getkeybyid(sys.argv[1], sys.argv[2])' 03683F77 keyserver.ubuntu.com
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/cloudinit/config/cc_apt_configure.py", line 113, in getkeybyid
    fh.write(EXPORT_GPG_KEYID)
  File "/usr/lib/python3.4/tempfile.py", line 556, in func_wrapper
    return func(*args, **kwargs)
TypeError: 'str' does not support the buffer interface

Fixes like this:
$ ( cd /usr/lib/python3/dist-packages/ && diff -u cloudinit/config/cc_apt_configure.py.dist cloudinit/config/cc_apt_configure.py )
--- cloudinit/config/cc_apt_configure.py.dist 2015-06-15 20:51:09.109033000 +0000
+++ cloudinit/config/cc_apt_configure.py 2015-06-15 20:51:16.185033000 +0000
@@ -109,7 +109,7 @@

 # get gpg keyid from keyserver
 def getkeybyid(keyid, keyserver):
- with util.ExtendedTemporaryFile(suffix='.sh') as fh:
+ with util.ExtendedTemporaryFile(suffix='.sh', mode="w+") as fh:
         fh.write(EXPORT_GPG_KEYID)
         fh.flush()
         cmd = ['/bin/sh', fh.name, keyid, keyserver]