boto/boto — pull request #2591 by nishigori (2014-09-05 14:07:40+00:00)
Title: [LaunchConfiguration] Fix user_data encoded Python 3.3+

Occurred the Error calling [`boto.ec2.autoscale.AutoScaleConnection.create_launch_configuration(...)`][src]

Hope to fix that behavior like [`boto.ec2.connection.run_instances`][src2] arguments type [`base64.b64encode()`](https://docs.python.org/3.4/library/base64.html#base64.b64encode)

| boto | 2.32.1 |
| -------- | ---------- |
| Python | py33, py34 |
| module | autoscale |
| Category | Bug |

[src]: https://github.com/boto/boto/blob/2.32.1/boto/ec2/autoscale/__init__.py#L212-260
[src2]: https://github.com/boto/boto/blob/2.32.1/boto/ec2/connection.py#L929-931

Traceback:

```
...
File "xxx/lib/python3.4/site-packages/boto/ec2/autoscale/__init__.py", line 225, in create_launch_configuration
params['UserData'] = base64.b64encode(launch_config.user_data).decode('utf-8')
File "xxx/lib/python3.4/base64.py", line 62, in b64encode
encoded = binascii.b2a_base64(s)[:-1]
TypeError: 'str' does not support the buffer interface
```

---

#### Test Execution

**Case 2.32.1:** :broken_heart:

```sh
$ python3 tests/test.py tests/unit/ec2/autoscale/test_group.py
nose command: tests/test.py -a !notdefault tests/unit/ec2/autoscale/test_group.py
...............E.......
======================================================================
ERROR: test_launch_config (tests.unit.ec2.autoscale.test_group.TestLaunchConfiguration)
----------------------------------------------------------------------
Traceback (most recent call last):
File "xxx/boto/boto/tests/unit/ec2/autoscale/test_group.py", line 375, in test_launch_config
response = self.service_connection.create_launch_configuration(lc)
File "xxx/boto/boto/ec2/autoscale/__init__.py", line 225, in create_launch_configuration
params['UserData'] = base64.b64encode(launch_config.user_data).decode('utf-8')
File "xxx/.venv/boto.py34/lib/python3.4/base64.py", line 62, in b64encode
encoded = binascii.b2a_base64(s)[:-1]
nose.proxy.TypeError: 'str' does not support the buffer interface
-------------------- >> begin captured logging << --------------------
boto: DEBUG: Using access key provided by client.
boto: DEBUG: Using secret key provided by client.
--------------------- >> end captured logging << ---------------------

----------------------------------------------------------------------
Ran 23 tests in 0.057s

FAILED (errors=1)
```

---

#### References

* [19.6. base64 - docs.python.org](https://docs.python.org/3.4/library/base64.html)
* [2.4.1 String and Bytes literals - docs.python.org](https://docs.python.org/3.4/reference/lexical_analysis.html#string-and-bytes-literals)
* [six.text_type - pythonhosted.org](https://pythonhosted.org/six/#six.text_type)