summaryrefslogtreecommitdiffstats
path: root/docs/docsite/rst/dev_guide/testing/sanity/no-get-exception.rst
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 16:04:21 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 16:04:21 +0000
commit8a754e0858d922e955e71b253c139e071ecec432 (patch)
tree527d16e74bfd1840c85efd675fdecad056c54107 /docs/docsite/rst/dev_guide/testing/sanity/no-get-exception.rst
parentInitial commit. (diff)
downloadansible-core-8a754e0858d922e955e71b253c139e071ecec432.tar.xz
ansible-core-8a754e0858d922e955e71b253c139e071ecec432.zip
Adding upstream version 2.14.3.upstream/2.14.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'docs/docsite/rst/dev_guide/testing/sanity/no-get-exception.rst')
-rw-r--r--docs/docsite/rst/dev_guide/testing/sanity/no-get-exception.rst28
1 files changed, 28 insertions, 0 deletions
diff --git a/docs/docsite/rst/dev_guide/testing/sanity/no-get-exception.rst b/docs/docsite/rst/dev_guide/testing/sanity/no-get-exception.rst
new file mode 100644
index 0000000..67f1646
--- /dev/null
+++ b/docs/docsite/rst/dev_guide/testing/sanity/no-get-exception.rst
@@ -0,0 +1,28 @@
+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:
+
+.. code-block:: python
+
+ # Unfixed code:
+ try:
+ raise IOError('test')
+ except IOError:
+ e = get_exception()
+ do_something(e)
+ except:
+ e = get_exception()
+ 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)