]> Cypherpunks.ru repositories - pyderasn.git/blobdiff - pyderasn.py
Auto add __slots__ to all inherited classes
[pyderasn.git] / pyderasn.py
index 4ae1eb0814182f065fa045d1c89b7a9f6c11e9ba..476e4e8bd7d60a1b174276fbeb99c4c3366c130d 100755 (executable)
@@ -318,6 +318,7 @@ from collections import OrderedDict
 from datetime import datetime
 from math import ceil
 
 from datetime import datetime
 from math import ceil
 
+from six import add_metaclass
 from six import binary_type
 from six import byte2int
 from six import indexbytes
 from six import binary_type
 from six import byte2int
 from six import indexbytes
@@ -655,6 +656,13 @@ def len_decode(data):
 # Base class
 ########################################################################
 
 # Base class
 ########################################################################
 
+class AutoAddSlots(type):
+    def __new__(cls, name, bases, _dict):
+        _dict["__slots__"] = _dict.get("__slots__", ())
+        return type.__new__(cls, name, bases, _dict)
+
+
+@add_metaclass(AutoAddSlots)
 class Obj(object):
     """Common ASN.1 object class
 
 class Obj(object):
     """Common ASN.1 object class