From 6200d32c0d577bc965d0111c1bf55aa16bb75ef7 Mon Sep 17 00:00:00 2001 From: Sam Doran Date: Tue, 4 Dec 2018 14:12:00 -0500 Subject: [PATCH] Use IndexError in exception (#49488) --- changelogs/fragments/reboot-fix-exception-type.yaml | 2 ++ lib/ansible/plugins/action/reboot.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/reboot-fix-exception-type.yaml diff --git a/changelogs/fragments/reboot-fix-exception-type.yaml b/changelogs/fragments/reboot-fix-exception-type.yaml new file mode 100644 index 0000000000..43f5680856 --- /dev/null +++ b/changelogs/fragments/reboot-fix-exception-type.yaml @@ -0,0 +1,2 @@ +bugfixes: + - reboot - use IndexError instead of TypeError in exception diff --git a/lib/ansible/plugins/action/reboot.py b/lib/ansible/plugins/action/reboot.py index a270de10e3..6b6470ea49 100644 --- a/lib/ansible/plugins/action/reboot.py +++ b/lib/ansible/plugins/action/reboot.py @@ -185,7 +185,7 @@ class ActionModule(ActionBase): if action_desc: try: error = to_text(e).splitlines()[-1] - except TypeError as e: + except IndexError as e: error = to_text(e) display.debug("{0}: {1} fail '{2}', retrying in {3:.4} seconds...".format(self._task.action, action_desc, error, fail_sleep))