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:46:09 +0200
commit04f1fa847612d448a9a0aecf7363d1fddd311872 (patch)
tree276061fbe75a7ab2c3b419a54fca255d4aba663e
parent551e4c9a69bf5a562abf498c84e66397ccfa8155 (diff)
downloadpysnmp-git-04f1fa847612d448a9a0aecf7363d1fddd311872.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] == '*':