THRIFT-4920: Fix generation of binary string constants
Currently, the thrift compiler generates regular string literals for
string constants marked as `binary`. This makes the resulting type
inconsistent under Python 3.
Client: python
This closes #1843.
diff --git a/compiler/cpp/src/thrift/generate/t_py_generator.cc b/compiler/cpp/src/thrift/generate/t_py_generator.cc
index 83462f4..982bca1 100644
--- a/compiler/cpp/src/thrift/generate/t_py_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_py_generator.cc
@@ -538,6 +538,9 @@
t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
switch (tbase) {
case t_base_type::TYPE_STRING:
+ if (((t_base_type*)type)->is_binary()) {
+ out << 'b';
+ }
out << '"' << get_escaped_string(value) << '"';
break;
case t_base_type::TYPE_BOOL: