From: Fredrik Tolf Date: Mon, 17 Jan 2022 02:18:35 +0000 (+0100) Subject: Make namedtype creation compatible with older Python versions. X-Git-Url: http://git.dolda2000.com/gitweb/?a=commitdiff_plain;h=ef6415d59129ca99fa4a0c23110a43ea6abe3a64;p=coe.git Make namedtype creation compatible with older Python versions. Not sure exactly where it changed. --- 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]