From ef6415d59129ca99fa4a0c23110a43ea6abe3a64 Mon Sep 17 00:00:00 2001 From: Fredrik Tolf Date: Mon, 17 Jan 2022 03:18:35 +0100 Subject: [PATCH] Make namedtype creation compatible with older Python versions. Not sure exactly where it changed. --- coe/bin.py | 2 +- coe/data.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/coe/bin.py b/coe/bin.py index 0e92bc6..e965a79 100644 --- a/coe/bin.py +++ b/coe/bin.py @@ -223,7 +223,7 @@ class decoder(object): buf[key] = self.loadtagged(fp, tag) def makeobjtype(self, nm): - return data.namedtype(str(nm), (data.obj, object), {}, typename=nm) + return data.namedtype.make(str(nm), (data.obj, object), {}, typename=nm) def loadobj(self, fp, ref=False): if ref: diff --git a/coe/data.py b/coe/data.py index aaa862d..f9fccb9 100644 --- a/coe/data.py +++ b/coe/data.py @@ -68,6 +68,12 @@ class namedtype(type): self.typename = typename return self + @classmethod + def make(cls, *args, typename=None, **kwargs): + self = cls(*args, **kwargs) + self.typename = typename + return self + class obj(object): def __getitem__(self, key): return self.__dict__[key] -- 2.11.0