THRIFT-5352: Fix construction of Py exceptions with no fields

Client: py

When no fields are present, we don't get the special constructor that
uses __setattr__ to avoid these checks. So the default constructor sets
message normally and triggers the anti-mutation tripwires.
diff --git a/lib/py/src/Thrift.py b/lib/py/src/Thrift.py
index ef655ea..81fe8cf 100644
--- a/lib/py/src/Thrift.py
+++ b/lib/py/src/Thrift.py
@@ -90,7 +90,7 @@
 
     def __init__(self, message=None):
         Exception.__init__(self, message)
-        self.message = message
+        super(TException, self).__setattr__("message", message)
 
 
 class TApplicationException(TException):
diff --git a/test/DebugProtoTest.thrift b/test/DebugProtoTest.thrift
index 1ab0f6a..5d0face 100644
--- a/test/DebugProtoTest.thrift
+++ b/test/DebugProtoTest.thrift
@@ -245,6 +245,8 @@
   1: string msg;
 } (python.immutable = "false")
 
+exception ExceptionWithoutFields {}
+
 service ServiceForExceptionWithAMap {
   void methodThatThrowsAnException() throws (1: ExceptionWithAMap xwamap);
 }
diff --git a/test/py/TestFrozen.py b/test/py/TestFrozen.py
index ce7425f..f859398 100755
--- a/test/py/TestFrozen.py
+++ b/test/py/TestFrozen.py
@@ -21,7 +21,7 @@
 
 from DebugProtoTest import Srv
 from DebugProtoTest.ttypes import CompactProtoTestStruct, Empty, Wrapper
-from DebugProtoTest.ttypes import ExceptionWithAMap, MutableException
+from DebugProtoTest.ttypes import ExceptionWithAMap, MutableException, ExceptionWithoutFields
 from thrift.Thrift import TFrozenDict
 from thrift.transport import TTransport
 from thrift.protocol import TBinaryProtocol, TCompactProtocol
@@ -104,6 +104,9 @@
         mutexc.msg = 'bar'
         self.assertEqual(mutexc.msg, 'bar')
 
+    def test_frozen_exception_with_no_fields(self):
+        ExceptionWithoutFields()
+
     def test_frozen_exception_serialization(self):
         result = Srv.declaredExceptionMethod_result(
             xwamap=ExceptionWithAMap(blah="error"))