Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions python/tvm/_ffi/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,13 @@
# this function is needed for python3
# to convert ctypes.char_p .value back to python str
if sys.platform == "win32":
encoding = 'cp' + str(ctypes.cdll.kernel32.GetACP())
py_str = lambda x: x.decode(encoding)
def _py_str(x):
try:
return x.decode('utf-8')
except UnicodeDecodeError:
encoding = 'cp' + str(ctypes.cdll.kernel32.GetACP())
return x.decode(encoding)
py_str = _py_str
else:
py_str = lambda x: x.decode('utf-8')
else:
Expand Down
7 changes: 7 additions & 0 deletions src/runtime/c_runtime_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,14 @@ std::string NormalizeError(std::string err_msg) {
if (!(is >> line)) return false;
// get filename
while (is.peek() == ' ') is.get();
#ifdef _MSC_VER // handle volume separator ":" in Windows path
std::string drive;
if (!getline(is, drive, ':')) return false;
if (!getline(is, file_name, ':')) return false;
file_name = drive + ":" + file_name;
#else
if (!getline(is, file_name, ':')) return false;
#endif
// get line number
if (!(is >> line_number)) return false;
// get rest of the message.
Expand Down