From e5c30776b510a88f760ca701558778b08a591e9d Mon Sep 17 00:00:00 2001 From: Ilya Etingof Date: Sun, 29 Jul 2018 08:48:50 +0200 Subject: Fix some typos and prepare for 0.4.5 --- CHANGES.rst | 5 +++++ pyasn1/__init__.py | 2 +- pyasn1/codec/ber/decoder.py | 4 ++++ pyasn1/codec/ber/encoder.py | 12 ++++++------ pyasn1/codec/cer/encoder.py | 2 +- pyasn1/error.py | 2 +- pyasn1/type/base.py | 12 ++++++------ pyasn1/type/constraint.py | 2 +- pyasn1/type/namedtype.py | 16 ++++++++-------- tests/codec/ber/test_decoder.py | 16 ++++++++-------- tests/codec/ber/test_encoder.py | 4 ++-- tests/type/test_constraint.py | 3 +-- tests/type/test_tag.py | 8 ++++---- tests/type/test_univ.py | 2 +- 14 files changed, 49 insertions(+), 41 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 542f726..0550873 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,4 +1,9 @@ +Revision 0.4.5, released XX-07-2018 +----------------------------------- + +No changes + Revision 0.4.4, released 26-07-2018 ----------------------------------- diff --git a/pyasn1/__init__.py b/pyasn1/__init__.py index e2e4c5c..68db4f1 100644 --- a/pyasn1/__init__.py +++ b/pyasn1/__init__.py @@ -1,7 +1,7 @@ import sys # https://www.python.org/dev/peps/pep-0396/ -__version__ = '0.4.4' +__version__ = '0.4.5' if sys.version_info[:2] < (2, 4): raise RuntimeError('PyASN1 requires Python 2.4 or later') diff --git a/pyasn1/codec/ber/decoder.py b/pyasn1/codec/ber/decoder.py index a27b3e0..514e91d 100644 --- a/pyasn1/codec/ber/decoder.py +++ b/pyasn1/codec/ber/decoder.py @@ -70,6 +70,10 @@ class ExplicitTagDecoder(AbstractSimpleDecoder): value, _ = decodeFun(head, asn1Spec, tagSet, length, **options) + if debug.logger & debug.flagDecoder: + debug.logger('explicit tag container carries %d octets of trailing payload (will be lost!): %s' % ( + len(_), debug.hexdump(_))) + return value, tail def indefLenValueDecoder(self, substrate, asn1Spec, diff --git a/pyasn1/codec/ber/encoder.py b/pyasn1/codec/ber/encoder.py index 0094b22..f77a8a5 100644 --- a/pyasn1/codec/ber/encoder.py +++ b/pyasn1/codec/ber/encoder.py @@ -305,7 +305,7 @@ class RealEncoder(AbstractItemEncoder): if m < 0: ms = -1 # mantissa sign if e < 0: - es = -1 # exponenta sign + es = -1 # exponent sign m *= ms if encbase == 8: m *= 2 ** (abs(e) % 3 * es) @@ -331,7 +331,7 @@ class RealEncoder(AbstractItemEncoder): return self._dropFloatingPoint(m, self.binEncBase, e) # auto choosing base 2/8/16 mantissa = [m, m, m] - exponenta = [e, e, e] + exponent = [e, e, e] sign = 1 encbase = 2 e = float('inf') @@ -339,9 +339,9 @@ class RealEncoder(AbstractItemEncoder): (sign, mantissa[i], encBase[i], - exponenta[i]) = self._dropFloatingPoint(mantissa[i], encBase[i], exponenta[i]) - if abs(exponenta[i]) < abs(e) or (abs(exponenta[i]) == abs(e) and mantissa[i] < m): - e = exponenta[i] + exponent[i]) = self._dropFloatingPoint(mantissa[i], encBase[i], exponent[i]) + if abs(exponent[i]) < abs(e) or (abs(exponent[i]) == abs(e) and mantissa[i] < m): + e = exponent[i] m = int(mantissa[i]) encbase = encBase[i] return sign, m, encbase, e @@ -364,7 +364,7 @@ class RealEncoder(AbstractItemEncoder): ms, m, encbase, e = self._chooseEncBase(value) if ms < 0: # mantissa sign fo |= 0x40 # sign bit - # exponenta & mantissa normalization + # exponent & mantissa normalization if encbase == 2: while m & 0x1 == 0: m >>= 1 diff --git a/pyasn1/codec/cer/encoder.py b/pyasn1/codec/cer/encoder.py index 768d3c1..fbe7cf5 100644 --- a/pyasn1/codec/cer/encoder.py +++ b/pyasn1/codec/cer/encoder.py @@ -41,7 +41,7 @@ class TimeEncoderMixIn(object): def encodeValue(self, value, asn1Spec, encodeFun, **options): # Encoding constraints: # - minutes are mandatory, seconds are optional - # - subseconds must NOT be zero + # - sub-seconds must NOT be zero # - no hanging fraction dot # - time in UTC (Z) # - only dot is allowed for fractions diff --git a/pyasn1/error.py b/pyasn1/error.py index c05e65c..31a221e 100644 --- a/pyasn1/error.py +++ b/pyasn1/error.py @@ -25,5 +25,5 @@ class SubstrateUnderrunError(PyAsn1Error): """Create pyasn1 exception object The `SubstrateUnderrunError` exception indicates insufficient serialised - data on input of a deserialisation routine. + data on input of a de-serialization routine. """ diff --git a/pyasn1/type/base.py b/pyasn1/type/base.py index adaab22..2f4ea4c 100644 --- a/pyasn1/type/base.py +++ b/pyasn1/type/base.py @@ -343,10 +343,10 @@ class AbstractSimpleAsn1Item(Asn1ItemBase): value = self._value - initilaizers = self.readOnly.copy() - initilaizers.update(kwargs) + initializers = self.readOnly.copy() + initializers.update(kwargs) - return self.__class__(value, **initilaizers) + return self.__class__(value, **initializers) def subtype(self, value=noValue, **kwargs): """Create a specialization of |ASN.1| schema or value object. @@ -540,10 +540,10 @@ class AbstractConstructedAsn1Item(Asn1ItemBase): """ cloneValueFlag = kwargs.pop('cloneValueFlag', False) - initilaizers = self.readOnly.copy() - initilaizers.update(kwargs) + initializers = self.readOnly.copy() + initializers.update(kwargs) - clone = self.__class__(**initilaizers) + clone = self.__class__(**initializers) if cloneValueFlag: self._cloneComponentValues(clone, cloneValueFlag) diff --git a/pyasn1/type/constraint.py b/pyasn1/type/constraint.py index a704331..15b887d 100644 --- a/pyasn1/type/constraint.py +++ b/pyasn1/type/constraint.py @@ -352,7 +352,7 @@ class InnerTypeConstraint(AbstractConstraint): if idx not in self.__multipleTypeConstraint: raise error.ValueConstraintError(value) constraint, status = self.__multipleTypeConstraint[idx] - if status == 'ABSENT': # XXX presense is not checked! + if status == 'ABSENT': # XXX presence is not checked! raise error.ValueConstraintError(value) constraint(value) diff --git a/pyasn1/type/namedtype.py b/pyasn1/type/namedtype.py index f162d19..0ce18df 100644 --- a/pyasn1/type/namedtype.py +++ b/pyasn1/type/namedtype.py @@ -265,18 +265,18 @@ class NamedTypes(object): return nameToPosMap def __computeAmbiguousTypes(self): - ambigiousTypes = {} - partialAmbigiousTypes = () + ambiguousTypes = {} + partialAmbiguousTypes = () for idx, namedType in reversed(tuple(enumerate(self.__namedTypes))): if namedType.isOptional or namedType.isDefaulted: - partialAmbigiousTypes = (namedType,) + partialAmbigiousTypes + partialAmbiguousTypes = (namedType,) + partialAmbiguousTypes else: - partialAmbigiousTypes = (namedType,) - if len(partialAmbigiousTypes) == len(self.__namedTypes): - ambigiousTypes[idx] = self + partialAmbiguousTypes = (namedType,) + if len(partialAmbiguousTypes) == len(self.__namedTypes): + ambiguousTypes[idx] = self else: - ambigiousTypes[idx] = NamedTypes(*partialAmbigiousTypes, **dict(terminal=True)) - return ambigiousTypes + ambiguousTypes[idx] = NamedTypes(*partialAmbiguousTypes, **dict(terminal=True)) + return ambiguousTypes def getTypeByPosition(self, idx): """Return ASN.1 type object by its position in fields set. diff --git a/tests/codec/ber/test_decoder.py b/tests/codec/ber/test_decoder.py index d456949..e8e17f0 100644 --- a/tests/codec/ber/test_decoder.py +++ b/tests/codec/ber/test_decoder.py @@ -333,7 +333,7 @@ class ObjectIdentifierDecoderTestCase(BaseTestCase): except PyAsn1Error: pass else: - assert 0, 'Leading 0x80 tolarated' + assert 0, 'Leading 0x80 tolerated' def testLeading0x80Case2(self): try: @@ -343,7 +343,7 @@ class ObjectIdentifierDecoderTestCase(BaseTestCase): except PyAsn1Error: pass else: - assert 0, 'Leading 0x80 tolarated' + assert 0, 'Leading 0x80 tolerated' def testLeading0x80Case3(self): try: @@ -353,7 +353,7 @@ class ObjectIdentifierDecoderTestCase(BaseTestCase): except PyAsn1Error: pass else: - assert 0, 'Leading 0x80 tolarated' + assert 0, 'Leading 0x80 tolerated' def testLeading0x80Case4(self): try: @@ -363,7 +363,7 @@ class ObjectIdentifierDecoderTestCase(BaseTestCase): except PyAsn1Error: pass else: - assert 0, 'Leading 0x80 tolarated' + assert 0, 'Leading 0x80 tolerated' def testTagFormat(self): try: @@ -379,7 +379,7 @@ class ObjectIdentifierDecoderTestCase(BaseTestCase): except PyAsn1Error: pass else: - assert 0, 'zero length tolarated' + assert 0, 'zero length tolerated' def testIndefiniteLength(self): try: @@ -429,12 +429,12 @@ class RealDecoderTestCase(BaseTestCase): ints2octs((9, 3, 160, 254, 1)) ) == (univ.Real((1, 2, -8)), null) - def testBin4(self): # check exponenta = 0 + def testBin4(self): # check exponent = 0 assert decoder.decode( # (1, 2, 0) encoded with base = 2 ints2octs((9, 3, 128, 0, 1)) ) == (univ.Real((1, 2, 0)), null) - def testBin5(self): # case of 2 octs for exponenta and negative exponenta + def testBin5(self): # case of 2 octs for exponent and negative exponent assert decoder.decode( # (3, 2, -1020) encoded with base = 16 ints2octs((9, 4, 161, 255, 1, 3)) ) == (univ.Real((3, 2, -1020)), null) @@ -1092,7 +1092,7 @@ class SetDecoderWithSchemaTestCase(BaseTestCase): ints2octs((49, 15, 5, 0, 4, 11, 113, 117, 105, 99, 107, 32, 98, 114, 111, 119, 110)), asn1Spec=self.s ) == (self.s, null) - def testWithOptionaIndefMode(self): + def testWithOptionalIndefMode(self): self.__initWithOptional() assert decoder.decode( ints2octs((49, 128, 5, 0, 36, 128, 4, 11, 113, 117, 105, 99, 107, 32, 98, 114, 111, 119, 110, 0, 0, 0, 0)), asn1Spec=self.s diff --git a/tests/codec/ber/test_encoder.py b/tests/codec/ber/test_encoder.py index 81368a9..62ea9cc 100644 --- a/tests/codec/ber/test_encoder.py +++ b/tests/codec/ber/test_encoder.py @@ -392,14 +392,14 @@ class RealEncoderTestCase(BaseTestCase): # choose binEncBase automatically for all further Real (testBin[4-7]) binEncBase, encoder.typeMap[univ.Real.typeId].binEncBase = encoder.typeMap[univ.Real.typeId].binEncBase, None assert encoder.encode( - univ.Real((1, 2, 0)) # check exponenta = 0 + univ.Real((1, 2, 0)) # check exponent = 0 ) == ints2octs((9, 3, 128, 0, 1)) encoder.typeMap[univ.Real.typeId].binEncBase = binEncBase def testBin5(self): assert encoder.encode( univ.Real((3, 2, -1020)) # case of 2 octs for exponent and - # negative exponenta and abs(exponent) is + # negative exponent and abs(exponent) is # all 1's and fills the whole octet(s) ) == ints2octs((9, 4, 129, 252, 4, 3)) diff --git a/tests/type/test_constraint.py b/tests/type/test_constraint.py index 2cdc66e..78d4e31 100644 --- a/tests/type/test_constraint.py +++ b/tests/type/test_constraint.py @@ -25,7 +25,7 @@ class SingleValueConstraintTestCase(BaseTestCase): self.c2 = constraint.SingleValueConstraint(3, 4) def testCmp(self): - assert self.c1 == self.c1, 'comparation fails' + assert self.c1 == self.c1, 'comparison fails' def testHash(self): assert hash(self.c1) != hash(self.c2), 'hash() fails' @@ -195,7 +195,6 @@ class InnerTypeConstraintTestCase(BaseTestCase): try: c(4, 0) except error.ValueConstraintError: - raise assert 0, 'constraint check fails' try: c(4, 1) diff --git a/tests/type/test_tag.py b/tests/type/test_tag.py index e0cf483..10e76d5 100644 --- a/tests/type/test_tag.py +++ b/tests/type/test_tag.py @@ -31,10 +31,10 @@ class TagReprTestCase(TagTestCaseBase): class TagCmpTestCase(TagTestCaseBase): def testCmp(self): - assert self.t1 == self.t2, 'tag comparation fails' + assert self.t1 == self.t2, 'tag comparison fails' def testHash(self): - assert hash(self.t1) == hash(self.t2), 'tag hash comparation fails' + assert hash(self.t1) == hash(self.t2), 'tag hash comparison fails' def testSequence(self): assert self.t1[0] == self.t2[0] and \ @@ -62,13 +62,13 @@ class TagSetReprTestCase(TagSetTestCaseBase): class TagSetCmpTestCase(TagSetTestCaseBase): def testCmp(self): - assert self.ts1 == self.ts2, 'tag set comparation fails' + assert self.ts1 == self.ts2, 'tag set comparison fails' def testHash(self): assert hash(self.ts1) == hash(self.ts2), 'tag set hash comp. fails' def testLen(self): - assert len(self.ts1) == len(self.ts2), 'tag length comparation fails' + assert len(self.ts1) == len(self.ts2), 'tag length comparison fails' class TaggingTestSuite(TagSetTestCaseBase): diff --git a/tests/type/test_univ.py b/tests/type/test_univ.py index ab44f3a..44a3add 100644 --- a/tests/type/test_univ.py +++ b/tests/type/test_univ.py @@ -1065,7 +1065,7 @@ class SequenceOf(BaseTestCase): else: assert False, 'IndexError not raised' - # this is a deviation from standart sequence protocol + # this is a deviation from standard sequence protocol assert not s[1] def testSetItem(self): -- cgit v1.2.1