From 33eb37e976d046f54e8772b1b76a2fb37f5b9dd2697dff71e0936236f3f70d19 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Thu, 5 Dec 2024 13:43:41 +0300 Subject: [PATCH] Yet another tiny optimisation --- pyac/pyac.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pyac/pyac.py b/pyac/pyac.py index 300bc67..0492841 100755 --- a/pyac/pyac.py +++ b/pyac/pyac.py @@ -366,7 +366,9 @@ def _loads(v, sets=False, leapsecUTCAllow=False, _allowContainers=True): if b == TagNInt: i, v = _int(v[1:]) return (-1 - i), v - if (b == TagList) and _allowContainers: + if not _allowContainers: + raise DecodeError("unknown tag") + if b == TagList: ret = [] v = v[1:] while True: @@ -375,7 +377,7 @@ def _loads(v, sets=False, leapsecUTCAllow=False, _allowContainers=True): break ret.append(i) return ret, v - if (b == TagMap) and _allowContainers: + if b == TagMap: ret = {} v = v[1:] kPrev = "" @@ -400,7 +402,7 @@ def _loads(v, sets=False, leapsecUTCAllow=False, _allowContainers=True): if sets and allNILs: ret = set(ret.keys()) return ret, v - if (b == TagBlob) and _allowContainers: + if b == TagBlob: if len(v) < 1+8: raise NotEnoughData(1+8-len(v)) l = 1 + int.from_bytes(v[1:1+8], "big") -- 2.51.0