Make namedtype creation compatible with older Python versions.
authorFredrik Tolf <fredrik@dolda2000.com>
Mon, 17 Jan 2022 02:18:35 +0000 (03:18 +0100)
committerFredrik Tolf <fredrik@dolda2000.com>
Mon, 17 Jan 2022 02:18:35 +0000 (03:18 +0100)
Not sure exactly where it changed.

coe/bin.py
coe/data.py

index 0e92bc6..e965a79 100644 (file)
@@ -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:
index aaa862d..f9fccb9 100644 (file)
@@ -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]