diff options
author | Vijay Vasudevan <vrv@google.com> | 2016-08-08 14:06:20 -0800 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2016-08-08 15:17:22 -0700 |
commit | 2d0d126749d6d0cf82fb86691362c923a1bfbfe4 (patch) | |
tree | 9823261d38fe3439326da4fdbef5ffb2c5adbfc2 /tensorflow/python/lib/core/strings.i | |
parent | 0204fbd5fec268e2b4d4d4e9185e21725a6c248d (diff) |
Change DeviceFactory functions that create devices to propagate
Statuses, so that failures to initialize devices don't crash
the program.
Changes swig for device_lib to be a lot simpler, thanks to mrry@
and keveman@'s help.
Change allocation of eigen scratch memory to go through the allocator.
Re-enable test for local devices now that python3 issue is fixed.
Change: 129678132
Diffstat (limited to 'tensorflow/python/lib/core/strings.i')
-rw-r--r-- | tensorflow/python/lib/core/strings.i | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/tensorflow/python/lib/core/strings.i b/tensorflow/python/lib/core/strings.i index 62741d9670..d2b0558882 100644 --- a/tensorflow/python/lib/core/strings.i +++ b/tensorflow/python/lib/core/strings.i @@ -80,7 +80,7 @@ bool _BytesToStringPiece(PyObject* obj, tensorflow::StringPiece* result) { } } -// Converts a C++ string vector to a Python string list. +// Converts a C++ string vector to a a list of Python bytes objects. %typemap(out) std::vector<string> { const int size = $1.size(); auto temp_string_list = tensorflow::make_safe(PyList_New(size)); @@ -90,11 +90,9 @@ bool _BytesToStringPiece(PyObject* obj, tensorflow::StringPiece* result) { tensorflow::Safe_PyObjectVector converted; converted.reserve(size); for (const string& op : $1) { -%#if PY_MAJOR_VERSION >= 3 - PyObject* py_str = PyUnicode_FromStringAndSize(op.data(), op.size()); -%#else - PyObject* py_str = PyString_FromStringAndSize(op.data(), op.size()); -%#endif + // Always treat strings as bytes, consistent with the typemap + // for string. + PyObject* py_str = PyBytes_FromStringAndSize(op.data(), op.size()); if (!py_str) { SWIG_fail; } |