From 9ffa84cc1ce8eea8275a09441032bf3ac5af1e60 Mon Sep 17 00:00:00 2001 From: Abhijeet Kasurde Date: Tue, 6 Oct 2020 20:55:51 +0530 Subject: [PATCH] basic: Handle exception in default selector (#72101) In Python 2.7, default selector raises IOError instead of OSError. Fix handles this exception. Fixes: #71704 Signed-off-by: Abhijeet Kasurde --- changelogs/fragments/71704_selector.yml | 2 ++ lib/ansible/module_utils/basic.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/71704_selector.yml diff --git a/changelogs/fragments/71704_selector.yml b/changelogs/fragments/71704_selector.yml new file mode 100644 index 00000000000..0ad93284f83 --- /dev/null +++ b/changelogs/fragments/71704_selector.yml @@ -0,0 +1,2 @@ +bugfixes: +- basic - handle exceptions for default selectors in Python 2.7 (https://github.com/ansible/ansible/issues/71704). diff --git a/lib/ansible/module_utils/basic.py b/lib/ansible/module_utils/basic.py index 00a04bf9048..1d03d5a2092 100644 --- a/lib/ansible/module_utils/basic.py +++ b/lib/ansible/module_utils/basic.py @@ -2712,7 +2712,7 @@ class AnsibleModule(object): stderr = b'' try: selector = selectors.DefaultSelector() - except OSError: + except (IOError, OSError): # Failed to detect default selector for the given platform # Select PollSelector which is supported by major platforms selector = selectors.PollSelector()