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()