diff options
Diffstat (limited to 'pysnmp/smi')
-rw-r--r-- | pysnmp/smi/mibs/INET-ADDRESS-MIB.py | 2 | ||||
-rw-r--r-- | pysnmp/smi/mibs/SNMPv2-TC.py | 6 |
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] == '*': |