mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
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
This commit is contained in:
parent
b2bd75a408
commit
6e7b89764e
1 changed files with 5 additions and 1 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue