From 5280ae917c4a49df1bb4ff354885bc046e7ee397 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Mon, 4 Mar 2019 11:48:45 -0500 Subject: [PATCH] updated as per fb --- lib/ansible/plugins/inventory/nmap.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/ansible/plugins/inventory/nmap.py b/lib/ansible/plugins/inventory/nmap.py index 72f2a140b47..41907c8b442 100644 --- a/lib/ansible/plugins/inventory/nmap.py +++ b/lib/ansible/plugins/inventory/nmap.py @@ -126,8 +126,13 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable): host = None ip = None ports = [] - for line in stdout.splitlines(): - line = to_text(line) + + try: + t_stdout = to_text(stdout, errors='surrogate_or_strict') + except UnicodeError as e: + raise AnsibleParserError('Invalid (non unicode) input returned: %s' % to_native(e)) + + for line in t_stdout.splitlines(): hits = self.find_host.match(line) if hits: if host is not None: