Tolerate duplicate enumerations
Possible duplicate enumerations in `Bits` and `Integer` SMI types causes pyasn1 exception. This fix reduces duplicates prior to passing them to pyasn1.community-table-to-ignore-bad-entries
parent
b2b10e75c5
commit
74434d710c
|
@ -54,6 +54,8 @@ Revision 4.4.6, released 2018-09-XX
|
|||
- Fixed `CommandGeneratorLcdConfigurator.unconfigure()` to fully clean up
|
||||
internal caches, otherwise repetitive attempts to configure the target
|
||||
would fail.
|
||||
- Fix to tolerate possible duplicate enumerations in `Bits` and `Integer`
|
||||
SMI types.
|
||||
|
||||
Revision 4.4.5, released 2018-08-05
|
||||
-----------------------------------
|
||||
|
|
|
@ -128,12 +128,17 @@ class Integer(Integer32):
|
|||
|
||||
@classmethod
|
||||
def withNamedValues(cls, **values):
|
||||
"""Creates a subclass with discreet named values constraint.
|
||||
"""Create a subclass with discreet named values constraint.
|
||||
|
||||
Reduce fully duplicate enumerations along the way.
|
||||
"""
|
||||
enums = set(cls.namedValues.items())
|
||||
enums.update(values.items())
|
||||
|
||||
class X(cls):
|
||||
namedValues = cls.namedValues + namedval.NamedValues(*values.items())
|
||||
subtypeSpec = cls.subtypeSpec + constraint.SingleValueConstraint(*values.values())
|
||||
namedValues = namedval.NamedValues(*enums)
|
||||
subtypeSpec = cls.subtypeSpec + constraint.SingleValueConstraint(
|
||||
*values.values())
|
||||
|
||||
X.__name__ = cls.__name__
|
||||
return X
|
||||
|
@ -637,10 +642,14 @@ class Bits(OctetString):
|
|||
@classmethod
|
||||
def withNamedBits(cls, **values):
|
||||
"""Creates a subclass with discreet named bits constraint.
|
||||
|
||||
Reduce fully duplicate enumerations along the way.
|
||||
"""
|
||||
enums = set(cls.namedValues.items())
|
||||
enums.update(values.items())
|
||||
|
||||
class X(cls):
|
||||
namedValues = cls.namedValues + namedval.NamedValues(*values.items())
|
||||
namedValues = namedval.NamedValues(*enums)
|
||||
|
||||
X.__name__ = cls.__name__
|
||||
return X
|
||||
|
|
Loading…
Reference in New Issue