f4d7b9a596
* Create get_exception and wildcard import code-smell tests * Add more detail to boilerplate and no-basestring descriptions * Remove the no-list-cmp test as the pylint undefined-variable test covers it
772 B
772 B
Sanity Tests » no-get-exception
We created a function,
ansible.module_utils.pycompat24.get_exception
to help
retrieve exceptions in a manner compatible with Python-2.4 through
Python-3.6. We no longer support Python-2.4 and Python-2.5 so this is
extraneous and we want to deprecate the function. Porting code should
look something like this:
# Unfixed code:
try:
raise IOError('test')
except IOError:
= get_excetion()
e
do_something(e)except:
= get_exception()
e
do_something_else(e)
# After fixing:
try:
raise IOError('test')
except IOErrors as e:
do_something(e)except Exception as e:
do_something_else(e)