X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;ds=sidebyside;f=pyderasn.py;h=54f2027f914df7db6d147dacde4d3daebf519a9e;hb=7decc606fe85d6c37a20ba48b14d80fcb1741443;hp=f611efa195369727b2a2a20455a8c5b796431389;hpb=df4edf45ae38fdde82784de40a95f6f0279f5e89;p=pyderasn.git diff --git a/pyderasn.py b/pyderasn.py index f611efa..54f2027 100755 --- a/pyderasn.py +++ b/pyderasn.py @@ -1287,11 +1287,13 @@ def file_mmaped(fd): """ return memoryview(mmap(fd.fileno(), 0, prot=PROT_READ)) + def pureint(value): if not set(value) <= DECIMALS: raise ValueError("non-pure integer") return int(value) + def fractions2float(fractions_raw): pureint(fractions_raw) return float("0." + fractions_raw) @@ -1304,7 +1306,7 @@ def get_def_by_path(defines_by_path, sub_decode_path): if len(path) != len(sub_decode_path): continue for p1, p2 in zip(path, sub_decode_path): - if (not p1 is any) and (p1 != p2): + if (p1 is not any) and (p1 != p2): break else: return define @@ -1963,7 +1965,7 @@ class Obj(object): yield None return _decode_path, obj, tail = result - if not _decode_path is decode_path: + if _decode_path is not decode_path: yield result else: try: @@ -2005,7 +2007,7 @@ class Obj(object): yield None return _decode_path, obj, tail = result - if not _decode_path is decode_path: + if _decode_path is not decode_path: yield result eoc_expected, tail = tail[:EOC_LEN], tail[EOC_LEN:] if eoc_expected.tobytes() != EOC: @@ -2044,7 +2046,7 @@ class Obj(object): yield None return _decode_path, obj, tail = result - if not _decode_path is decode_path: + if _decode_path is not decode_path: yield result if obj.tlvlen < l and not ctx.get("allow_expl_oob", False): raise DecodeError( @@ -3373,7 +3375,7 @@ class BitString(Obj): int2byte(0), octets[offset:offset + 999], ))) - tail = octets[offset+999:] + tail = octets[offset + 999:] if len(tail) > 0: tail = int2byte((8 - bit_len % 8) % 8) + tail write_full(writer, b"".join(( @@ -3833,7 +3835,7 @@ class OctetString(Obj): LEN1K, octets[offset:offset + 1000], ))) - tail = octets[offset+1000:] + tail = octets[offset + 1000:] if len(tail) > 0: write_full(writer, b"".join(( OctetString.tag_default,