You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@thrift.apache.org by "andrewcunnin (via GitHub)" <gi...@apache.org> on 2023/04/17 17:27:46 UTC
[GitHub] [thrift] andrewcunnin commented on a diff in pull request #2783: THRIFT-5693 - fix bug in serialization of enum default values
andrewcunnin commented on code in PR #2783:
URL: https://github.com/apache/thrift/pull/2783#discussion_r1169057089
##########
compiler/cpp/src/thrift/generate/t_py_generator.cc:
##########
@@ -2662,6 +2662,11 @@ string t_py_generator::declare_argument(t_field* tfield) {
string t_py_generator::render_field_default_value(t_field* tfield) {
t_type* type = get_true_type(tfield->get_type());
if (tfield->get_value() != nullptr) {
+ if (type->is_enum() && gen_enum_) {
+ std::ostringstream out;
+ out << tfield->get_value()->get_integer();
+ return out.str();
+ }
Review Comment:
Ah, good catch. That default value change was because I thought Thrift was generally expecting int values even representing Python enums, but after re-testing I've found that that was only an issue for serialization and deserialization. Removed that change and here's the updated diff: https://gist.github.com/andrewcunnin/ba688afe22f943c7b9f96e67adb3bc53
--
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: notifications-unsubscribe@thrift.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org