fishy commented on code in PR #2816:
URL: https://github.com/apache/thrift/pull/2816#discussion_r1239085659


##########
compiler/cpp/src/thrift/generate/t_py_generator.cc:
##########
@@ -888,12 +888,33 @@ void 
t_py_generator::generate_py_struct_definition(ostream& out,
 
   if (is_immutable(tstruct)) {
     out << endl;
-    out << indent() << "def __setattr__(self, *args):" << endl
-        << indent() << indent_str() << "raise TypeError(\"can't modify 
immutable instance\")" << endl
-        << endl;
-    out << indent() << "def __delattr__(self, *args):" << endl
-        << indent() << indent_str() << "raise TypeError(\"can't modify 
immutable instance\")" << endl
-        << endl;
+    out << indent() << "def __setattr__(self, attr, value):" << endl;
+    indent_up();
+    if (gen_slots_) {
+      out << indent() << "if attr not in self.__slots__:" << endl;
+    } else {
+      out << indent() << "if not self.__dict__.has_key(attr):" << endl;

Review Comment:
   my main concern here is that after contextmanager changes the 
`__traceback__` it will start to appear in `__dict__` and then it can no longer 
be changed again



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to