From 6e7b89764e5d802016279429d2f4a03b3dedc444 Mon Sep 17 00:00:00 2001 From: Adrian Likins Date: Wed, 22 Feb 2017 09:32:20 -0500 Subject: [PATCH] Fix snmp_facts error on decode_hex() (#21694) * Fix snmp_facts error on decode_hex() Remove use of some_string.decode('hex') that fails on py3, and replace with to_binascii.unhexlify() Fixes #21668 --- lib/ansible/modules/network/snmp_facts.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/network/snmp_facts.py b/lib/ansible/modules/network/snmp_facts.py index e28b733c3f..fe16f5c1e6 100644 --- a/lib/ansible/modules/network/snmp_facts.py +++ b/lib/ansible/modules/network/snmp_facts.py @@ -95,7 +95,11 @@ EXAMPLES = ''' delegate_to: localhost ''' +import binascii + from ansible.module_utils.basic import * +from ansible.module_utils._text import to_text + from collections import defaultdict try: @@ -141,7 +145,7 @@ def decode_hex(hexstring): if len(hexstring) < 3: return hexstring if hexstring[:2] == "0x": - return hexstring[2:].decode("hex") + return to_text(binascii.unhexlify(hexstring[2:])) else: return hexstring