summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene M. Kim <astralblue@gmail.com>2017-10-17 15:13:50 -0700
committerIlya Etingof <etingof@gmail.com>2017-10-18 00:13:50 +0200
commit78ee2edfce79524cc903e6f9569caf4820f7ef90 (patch)
tree9be838aa7ddca71d2f1a9689b92cd23bb780c115
parenta6abfd82662615f5e136194e00072afdea1e1510 (diff)
downloadpysnmp-git-78ee2edfce79524cc903e6f9569caf4820f7ef90.tar.gz
Fix InetAddress-to-InetAddressIPv{4,6} index cast (#97)
* Fix InetAddress-to-InetAddressIPv{4,6} index cast Previously, the pretty value of the InetAddress instance was being used. Since InetAddress does not know how to format the raw octets to protocol-specific syntax (IPv4 or IPv6), the pretty value was something like u'\x00\x00\x00\x00' instead of u'0.0.0.0', which in turn caused parse error in the protocol-specific subclass. Passing the raw value (4- or 16-byte octet string) itself works as the protocol-specific subclasses know how to handle these.
-rw-r--r--pysnmp/smi/mibs/INET-ADDRESS-MIB.py4
1 files changed, 1 insertions, 3 deletions
diff --git a/pysnmp/smi/mibs/INET-ADDRESS-MIB.py b/pysnmp/smi/mibs/INET-ADDRESS-MIB.py
index 481c55bc..e6530df5 100644
--- a/pysnmp/smi/mibs/INET-ADDRESS-MIB.py
+++ b/pysnmp/smi/mibs/INET-ADDRESS-MIB.py
@@ -90,9 +90,7 @@ class InetAddress(TextualConvention, OctetString):
for parentIndex in reversed(parentIndices):
if isinstance(parentIndex, InetAddressType):
try:
- # TODO: newer pyasn1 should ensure .prettyPrint() returns unicode
- prettyValue = self.asOctets().decode()
- return parentRow.getAsName(self.typeMap[parentIndex].clone(prettyValue), impliedFlag, parentIndices)
+ return parentRow.getAsName(self.typeMap[parentIndex].clone(self.asOctets()), impliedFlag, parentIndices)
except KeyError:
pass