diff options
author | Elvis Pranskevichus <elvispranskevichus@pinterest.com> | 2019-12-11 16:47:52 -0500 |
---|---|---|
committer | Duru Can Celasun <can@dcc.im> | 2019-12-12 13:50:42 +0000 |
commit | 9c43962da8e4b530014619e3703a279053cf2182 (patch) | |
tree | 9b862189ed6e5fbdd9819a964c7f2efe69aa9bb4 /lib/py | |
parent | 9320f891d7d972fc2cc4f9569b66767c5dfc4242 (diff) | |
download | thrift-9c43962da8e4b530014619e3703a279053cf2182.tar.gz |
Revert "Revert "THRIFT-4002: Make generated exception classes immutable by default""
This reverts commit 1234ddf8a5c98d5d700c82e087f04725170ad581.
Diffstat (limited to 'lib/py')
-rw-r--r-- | lib/py/src/protocol/TBase.py | 4 | ||||
-rw-r--r-- | lib/py/src/protocol/TProtocol.py | 10 |
2 files changed, 12 insertions, 2 deletions
diff --git a/lib/py/src/protocol/TBase.py b/lib/py/src/protocol/TBase.py index 9ae1b1182..6c6ef18e8 100644 --- a/lib/py/src/protocol/TBase.py +++ b/lib/py/src/protocol/TBase.py @@ -80,3 +80,7 @@ class TFrozenBase(TBase): [self.__class__, self.thrift_spec]) else: return iprot.readStruct(cls, cls.thrift_spec, True) + + +class TFrozenExceptionBase(TFrozenBase, TExceptionBase): + pass diff --git a/lib/py/src/protocol/TProtocol.py b/lib/py/src/protocol/TProtocol.py index 3456e8f0e..339a2839d 100644 --- a/lib/py/src/protocol/TProtocol.py +++ b/lib/py/src/protocol/TProtocol.py @@ -303,8 +303,14 @@ class TProtocolBase(object): def readContainerStruct(self, spec): (obj_class, obj_spec) = spec - obj = obj_class() - obj.read(self) + + # If obj_class.read is a classmethod (e.g. in frozen structs), + # call it as such. + if getattr(obj_class.read, '__self__', None) is obj_class: + obj = obj_class.read(self) + else: + obj = obj_class() + obj.read(self) return obj def readContainerMap(self, spec): |