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


##########
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:
   Long story short, `__traceback__` does not appear in `__dict__` from what I 
could track down it's because the implementation of `Exception` is in C and 
`__traceback__` is not technically an official property.
   
   Fishy and I discussed off PR and decided that it was acceptable to only 
support context managers (in Python 3.11) with when using slots. This means any 
user that runs into this issue should use slots to get around their issue.



-- 
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