forked from Thriftpy/thriftpy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Treat binary and string fields differently
I believe this improves [1] which addresses a bytes/str inconsistency issue reported some time ago[2]. The goal of this patch is to have an option to always deseriaize binary fields as bytes and string fields as str (on Python 2, respectively: str and unicode). It achieves it by adding a third option to previously purely boolean decode_response parameter (I admit I'm not a fan of mixing types like this but I'm doing this strictly for backwards compatibility and I'd argue the "auto" behavior should become the default in the future and decode_response should be removed altogether). I'm not intimately familiar with Thrift specification so adding a separate ttype like this may be stupid - let me know if that is so. I've renamed and reorganized parts of the code in order for the names to be reasonably truthful and to avoid too much code redundancy connected to the fact that I've added more tests. Ideally some of the test code would be shared so reduce the redundancy even further but I feel that it's out of scope here. (Similarly the actual non-test code - I'm not entirely comfortable with the redundancy this commit introduces but there's quite a bit of redundancy in the code already so improving this is likely a whole separate task. Also extracting the logic to a separate function would negatively impact the performance /possibly not important/ but it could also make the code less readable, I'm conflicted here). [1] Thriftpy@00c6553 [2] Thriftpy#190
- Loading branch information
Showing
8 changed files
with
181 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.