spladug opened a new pull request #2330:
URL: https://github.com/apache/thrift/pull/2330


   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.
   
   Before:
   
   ```console
   $ thrift --version
   Thrift version 0.14.0
   
   $ pip freeze | grep thrift
   thrift==0.14.0
   
   $ cat test.thrift
   exception LookMaNoFields {}
   
   $ thrift -out . -gen py test.thrift
   
   $ python
   >>> from test.ttypes import LookMaNoFields
   >>> LookMaNoFields()
   Traceback (most recent call last):
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
     File "/src/thrift/lib/py/thrift/Thrift.py", line 93, in __init__
       super(TException, self).__setattr__("message", message)
     File "/src/example/test/ttypes.py", line 23, in __setattr__
       raise TypeError("can't modify immutable instance")
   TypeError: can't modify immutable instance
   ```
   
   After:
   
   ```
   $ python
   >>> from test.ttypes import LookMaNoFields
   >>> LookMaNoFields()
   LookMaNoFields(message=None)
   ```
   
   
   - [x] Did you create an [Apache 
Jira](https://issues.apache.org/jira/projects/THRIFT/issues/) ticket?  (not 
required for trivial changes)
   - [x] If a ticket exists: Does your pull request title follow the pattern 
"THRIFT-NNNN: describe my issue"?
   - [x] Did you squash your changes to a single commit?  (not required, but 
preferred)
   - [x] Did you do your best to avoid breaking changes?  If one was needed, 
did you label the Jira ticket with "Breaking-Change"?
   - [x] If your change does not involve any code, include `[skip ci]` anywhere 
in the commit message to free up build resources.
   
   <!--
     The Contributing Guide at:
     https://github.com/apache/thrift/blob/master/CONTRIBUTING.md
     has more details and tips for committing properly.
   -->
   


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

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


Reply via email to