summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlya Etingof <etingof@gmail.com>2018-04-21 17:11:54 +0200
committerIlya Etingof <etingof@gmail.com>2018-04-21 17:11:54 +0200
commit1021d56e1b1472c570d395d73d1c1c73bbf7761a (patch)
tree34ee5faae51348d6f81136e75873291dff620c78
parentc41957644565b511471cece15eabaa0c47c2ad3b (diff)
downloadpysnmp-git-1021d56e1b1472c570d395d73d1c1c73bbf7761a.tar.gz
better InetAddressType rendering fix
-rw-r--r--pysnmp/smi/mibs/INET-ADDRESS-MIB.py2
-rw-r--r--pysnmp/smi/mibs/SNMPv2-TC.py6
2 files changed, 5 insertions, 3 deletions
diff --git a/pysnmp/smi/mibs/INET-ADDRESS-MIB.py b/pysnmp/smi/mibs/INET-ADDRESS-MIB.py
index 3ce2cd55..5e40017c 100644
--- a/pysnmp/smi/mibs/INET-ADDRESS-MIB.py
+++ b/pysnmp/smi/mibs/INET-ADDRESS-MIB.py
@@ -90,7 +90,7 @@ class InetAddress(TextualConvention, OctetString):
for parentIndex in reversed(parentIndices):
if isinstance(parentIndex, InetAddressType):
try:
- return parentRow.getAsName(self.typeMap[int(parentIndex)].clone(str(self)), impliedFlag, parentIndices)
+ return parentRow.getAsName(self.typeMap[int(parentIndex)].clone(self.asOctets().decode('ascii')), impliedFlag, parentIndices)
except KeyError:
pass
diff --git a/pysnmp/smi/mibs/SNMPv2-TC.py b/pysnmp/smi/mibs/SNMPv2-TC.py
index 2e49352a..c07e7e2c 100644
--- a/pysnmp/smi/mibs/SNMPv2-TC.py
+++ b/pysnmp/smi/mibs/SNMPv2-TC.py
@@ -184,7 +184,7 @@ class TextualConvention(object):
"""Implements DISPLAY-HINT parsing into base SNMP value
Proper parsing seems impossible due to ambiguities.
- Here we are truing to do our best, but be prepared
+ Here we are trying to do our best, but be prepared
for failures on complicated DISPLAY-HINTs.
Keep in mind that this parser only works with "text"
@@ -259,7 +259,8 @@ class TextualConvention(object):
# how do we know if object is initialized with display-hint
# formatted text? based on "text" input maybe?
- if octets.isStringType(value):
+ # That boils down to `str` object on Py3 or `unicode` on Py2.
+ if octets.isStringType(value) and not octets.isOctetsType(value):
value = base.prettyIn(self, value)
else:
return base.prettyIn(self, value)
@@ -267,6 +268,7 @@ class TextualConvention(object):
outputValue = octets.str2octs('')
runningValue = value
displayHint = self.displayHint
+
while runningValue and displayHint:
# 1 this information is totally lost, just fail explicitly
if displayHint[0] == '*':