# Travis build process failing to compile with python3

**URL:** <https://forum.ansible.com/t/travis-build-process-failing-to-compile-with-python3/21520>\
**Category:** Ansible Developer\
**Created:** [May 23, 2016, 3:39am UTC](https://forum.ansible.com/t/travis-build-process-failing-to-compile-with-python3/21520 "2016-05-23T03:39:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rob\_White](https://avatars.discourse-cdn.com/v4/letter/r/71c47a/32.png) [@Rob\_White](https://forum.ansible.com/u/Rob_White)\
**Post date:** [May 23, 2016, 3:39am UTC](https://forum.ansible.com/t/travis-build-process-failing-to-compile-with-python3/21520/1 "2016-05-23T03:39:07Z")

</div>

Does any one know why Travis has started to fail builds by trying to compile with python3?

Example:

```auto

0.66s$ python3.4 -m compileall -fq . -x $(echo "$PY3_EXCLUDE_LIST"| tr ' ' '|')

*** Error compiling './cloud/amazon/iam_mfa_device_facts.py'...

  File "./cloud/amazon/iam_mfa_device_facts.py", line 85

    except ClientError, e:

                      ^

SyntaxError: invalid syntax

```

Last i heard, Ansible was supposed to be 2.4 compatible so rewriting the above as `except ClientError as e:` would be incorrect.

What gives?

---

<div class="post-metadata">

**Author:** ![Toshio\_Kuratomi](https://avatars.discourse-cdn.com/v4/letter/t/41988e/32.png) [@Toshio\_Kuratomi](https://forum.ansible.com/u/Toshio_Kuratomi)\
**Post date:** [May 23, 2016, 10:36am UTC](https://forum.ansible.com/t/travis-build-process-failing-to-compile-with-python3/21520/2 "2016-05-23T10:36:03Z")

</div>

We’re slowly moving to the place where modules are usable on python3 as well as python2. This is not likely to be reliably usable by 2.2 but you’ll start to see a few modules that you can use on py3 when we release.

As a first step we’re starting to get modules to syntax compile with python3 as well as python2. There’s a blacklist in the testing so we should only be attempting to compile modules which were compiLing in the past (so we don’t regress).

For exceptions, there’s two possibilities for porting the code:

- if the module can’t run on python2.4 (because one of its library dependencies requires python2.6 and above) then go ahead and switch to catching the exception via “except ClientError as e:” The module should already document that it requires python2.6 sand above in its requirements action.

- otherwise the module will need to use some helper code to retrieve the exception in a way compatible with python2.4 and python3:

from ansible.module\_utils.pycompat24 import get\_exception  
[…]  
try:  
raise ClientError(msg)  
except ClientError:  
e = get\_exception()

- toshio

---

<div class="post-metadata">

**Author:** ![Rob\_White](https://avatars.discourse-cdn.com/v4/letter/r/71c47a/32.png) [@Rob\_White](https://forum.ansible.com/u/Rob_White)\
**Post date:** [May 23, 2016, 11:20am UTC](https://forum.ansible.com/t/travis-build-process-failing-to-compile-with-python3/21520/3 "2016-05-23T11:20:33Z")

</div>

ah ok. Makes sense. Thanks for the explanation.

I’ll update the AWS guidelines as boto3 requires 2.6+
