diff options
author | Ilya Etingof <etingof@gmail.com> | 2019-06-23 09:15:46 +0200 |
---|---|---|
committer | Ilya Etingof <etingof@gmail.com> | 2019-06-23 09:15:46 +0200 |
commit | d75f2fdb4c147d29bed33bacc03466455908d2f8 (patch) | |
tree | 2e5430474c3b688985f32b2a9b05fcf122390f52 | |
parent | b7971b98a5448e735184339c99f3401bb12630de (diff) | |
download | pysnmp-git-d75f2fdb4c147d29bed33bacc03466455908d2f8.tar.gz |
Fix `var-bindings` initialization
Set `var-bindings` to an empty sequence by default. Otherwise
it can remain a "pyasn1 schema object" failing to encode. This
can happen with newer pyasn1 versions where `SequenceOf` type
does not have default initializer.
-rw-r--r-- | CHANGES.txt | 3 | ||||
-rw-r--r-- | pysnmp/proto/api/v1.py | 6 | ||||
-rw-r--r-- | pysnmp/proto/api/v2c.py | 3 |
3 files changed, 9 insertions, 3 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 90454a5d..778ed8a7 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -7,6 +7,9 @@ Revision 4.4.10, released 2019-04-XX - Fixed asyncore main loop to respect non-default timer resolution - Fixed `.setTimerResolution()` behaviour of abstract main loop dispatcher to update call intervals of the existing periodic dispatcher jobs +- Fixed `var-bindings` initialization to prevent pyasn1 encoder failures + with newer pyasn1 versions where `SequenceOf` type looses its default + initializer. Revision 4.4.9, released 2019-02-09 ----------------------------------- diff --git a/pysnmp/proto/api/v1.py b/pysnmp/proto/api/v1.py index 1f968986..37882859 100644 --- a/pysnmp/proto/api/v1.py +++ b/pysnmp/proto/api/v1.py @@ -66,7 +66,8 @@ class PDUAPI(object): pdu.setComponentByPosition( 2, self._errorIndex, verifyConstraints=False, matchTags=False, matchConstraints=False ) - pdu.setComponentByPosition(3) + varBindList = pdu.setComponentByPosition(3).getComponentByPosition(3) + varBindList.clear() @staticmethod def getRequestID(pdu): @@ -170,7 +171,8 @@ class TrapPDUAPI(object): pdu.setComponentByPosition(2, self._genericTrap, verifyConstraints=False, matchTags=False, matchConstraints=False) pdu.setComponentByPosition(3, self._zeroInt, verifyConstraints=False, matchTags=False, matchConstraints=False) pdu.setComponentByPosition(4, self._zeroTime, verifyConstraints=False, matchTags=False, matchConstraints=False) - pdu.setComponentByPosition(5) + varBindList = pdu.setComponentByPosition(5).getComponentByPosition(5) + varBindList.clear() @staticmethod def getEnterprise(pdu): diff --git a/pysnmp/proto/api/v2c.py b/pysnmp/proto/api/v2c.py index 656c88f4..b21ecf36 100644 --- a/pysnmp/proto/api/v2c.py +++ b/pysnmp/proto/api/v2c.py @@ -91,7 +91,8 @@ class BulkPDUAPI(PDUAPI): pdu.setComponentByPosition( 2, self._maxRepetitions, verifyConstraints=False, matchTags=False, matchConstraints=False ) - pdu.setComponentByPosition(3) + varBindList = pdu.setComponentByPosition(3).getComponentByPosition(3) + varBindList.clear() @staticmethod def getNonRepeaters(pdu): |