summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene M. Kim <astralblue@gmail.com>2017-10-14 01:42:28 -0700
committerIlya Etingof <etingof@gmail.com>2017-10-14 10:42:28 +0200
commitcd8d66f8a164a3bc7bf584826fd17c79fac6d428 (patch)
tree76ef51fa5a08068e6e0e47385c9728c7c6fbb376
parent37551d92711eafaff041ad637b05b586dbf17887 (diff)
downloadpysnmp-git-cd8d66f8a164a3bc7bf584826fd17c79fac6d428.tar.gz
Do not cache indices with a mutable index value (#94)
NetworkAddress is one such index value.
-rw-r--r--pysnmp/smi/mibs/SNMPv2-SMI.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/pysnmp/smi/mibs/SNMPv2-SMI.py b/pysnmp/smi/mibs/SNMPv2-SMI.py
index 47710304..cc20bd82 100644
--- a/pysnmp/smi/mibs/SNMPv2-SMI.py
+++ b/pysnmp/smi/mibs/SNMPv2-SMI.py
@@ -1230,8 +1230,12 @@ class MibTableRow(MibTree):
def getInstIdFromIndices(self, *indices):
"""Return column instance identification from indices"""
- if indices in self.__idxToIdCache:
+ try:
return self.__idxToIdCache[indices]
+ except TypeError:
+ cacheable = False
+ except KeyError:
+ cacheable = True
idx = 0
instId = ()
parentIndices = []
@@ -1243,7 +1247,8 @@ class MibTableRow(MibTree):
instId += self.getAsName(syntax, impliedFlag, parentIndices)
parentIndices.append(syntax)
idx += 1
- self.__idxToIdCache[indices] = instId
+ if cacheable:
+ self.__idxToIdCache[indices] = instId
return instId
# Table access by index