ResourceHandleShapeAndType returns bytes, not unicode.
authorSkye Wanderman-Milne <skyewm@google.com>
Mon, 2 Apr 2018 21:40:37 +0000 (14:40 -0700)
committerTensorFlower Gardener <gardener@tensorflow.org>
Mon, 2 Apr 2018 21:42:57 +0000 (14:42 -0700)
This could cause failures when enabling the C API with python3.

PiperOrigin-RevId: 191350031

tensorflow/python/client/tf_session.i

index 5dcd0c1..ee76e29 100644 (file)
@@ -460,6 +460,11 @@ TF_ImportGraphDefResultsMissingUnusedInputMappings_wrapper{
   $1 = PyLong_AsLongLong($input);
 }
 
+// Override default py3 behavior of attempting to encode into Unicode.
+%typemap(out) std::string tensorflow::ResourceHandleShapeAndType {
+  $result = PyBytes_FromStringAndSize($1.data(), $1.size());
+}
+
 // TODO(skyewm): SWIG emits a warning for the const char* in TF_WhileParams,
 // skip for now
 %ignore TF_WhileParams;