← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1423972] Re: cloud-init user-data mime conversion fails on base64 encoded data

 

** Package changed: ubuntu => cloud-init (Ubuntu)

** Changed in: cloud-init (Ubuntu)
    Milestone: ubuntu-15.03 => None

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to cloud-init.
https://bugs.launchpad.net/bugs/1423972

Title:
  cloud-init user-data mime conversion fails on base64 encoded data

Status in cloud-init:
  Fix Committed
Status in cloud-init package in Ubuntu:
  In Progress

Bug description:
  Cloud-init's conversion of user-data to mime fails when the user-data
  is base64 encoded due to the Python2 to Python3 switch.
  base64.b64decode in Python 2 returns a string, whilst Python3 returns
  a byte stream.

  Consider:
        import base64

        hi = "aGkK"
        print(type(base64.b64decode(hi)).__name__)
        if 'hi' in str(base64.b64decode(hi)):
           print("works")
        if 'hi' in base64.b64decode(hi):
           print("works on Py2")

  ben@prongs:~$ python /tmp/proof.py 
  str
  works
  works on Py2
  ben@prongs:~$ python3 /tmp/proof.py 
  bytes
  works
  Traceback (most recent call last):
    File "/tmp/proof.py", line 10, in <module>
      if 'hi' in base64.b64decode(hi):
  TypeError: Type str doesn't support the buffer API

To manage notifications about this bug go to:
https://bugs.launchpad.net/cloud-init/+bug/1423972/+subscriptions