Browse Source

pyext: missing cast to constant char* (#5713)

We need to cast to a constant charpointer here.
grindhold 6 years ago
parent
commit
3a538fc91e
1 changed files with 5 additions and 3 deletions
  1. 5 3
      python/google/protobuf/pyext/message_factory.cc

+ 5 - 3
python/google/protobuf/pyext/message_factory.cc

@@ -43,9 +43,11 @@
     #error "Python 3.0 - 3.2 are not supported."
   #endif
   #define PyString_AsStringAndSize(ob, charpp, sizep) \
-    (PyUnicode_Check(ob)? \
-       ((*(charpp) = PyUnicode_AsUTF8AndSize(ob, (sizep))) == NULL? -1: 0): \
-       PyBytes_AsStringAndSize(ob, (charpp), (sizep)))
+    (PyUnicode_Check(ob) ? ((*(charpp) = const_cast<char*>(                   \
+                               PyUnicode_AsUTF8AndSize(ob, (sizep)))) == NULL \
+                              ? -1                                            \
+                              : 0)                                            \
+                        : PyBytes_AsStringAndSize(ob, (charpp), (sizep)))
 #endif
 
 namespace google {