You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by li...@apache.org on 2020/06/21 22:06:14 UTC
[incubator-tvm] branch v0.6 updated: [BACKPORT-0.6][FFI][Windows]
Fix hasattr by extracting Python error type from Windows error message
(#5873)
This is an automated email from the ASF dual-hosted git repository.
liuyizhi pushed a commit to branch v0.6
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git
The following commit(s) were added to refs/heads/v0.6 by this push:
new aef828c [BACKPORT-0.6][FFI][Windows] Fix hasattr by extracting Python error type from Windows error message (#5873)
aef828c is described below
commit aef828ca30836aa94841d19876581aa8e97b74dd
Author: Yizhi Liu <li...@apache.org>
AuthorDate: Sun Jun 21 15:06:07 2020 -0700
[BACKPORT-0.6][FFI][Windows] Fix hasattr by extracting Python error type from Windows error message (#5873)
Co-authored-by: Jon Soifer <so...@gmail.com>
---
python/tvm/_ffi/base.py | 29 +++++++++++++++++++++++------
1 file changed, 23 insertions(+), 6 deletions(-)
diff --git a/python/tvm/_ffi/base.py b/python/tvm/_ffi/base.py
index 66a8927..6aa12d0 100644
--- a/python/tvm/_ffi/base.py
+++ b/python/tvm/_ffi/base.py
@@ -199,13 +199,30 @@ def _find_error_type(line):
-------
name : str The error name
"""
- end_pos = line.find(":")
- if end_pos == -1:
+ if sys.platform == "win32":
+ # Stack traces aren't logged on Windows due to a DMLC limitation,
+ # so we should try to get the underlying error another way.
+ # DMLC formats errors "[timestamp] file:line: ErrorMessage"
+ # ErrorMessage is usually formatted "ErrorType: message"
+ # We can try to extract the error type using the final ":"
+ end_pos = line.rfind(":")
+ if end_pos == -1:
+ return None
+ start_pos = line.rfind(":", 0, end_pos)
+ if start_pos == -1:
+ return None
+ err_name = line[start_pos + 1 : end_pos].strip()
+ if _valid_error_name(err_name):
+ return err_name
+ return None
+ else:
+ end_pos = line.find(":")
+ if end_pos == -1:
+ return None
+ err_name = line[:end_pos]
+ if _valid_error_name(err_name):
+ return err_name
return None
- err_name = line[:end_pos]
- if _valid_error_name(err_name):
- return err_name
- return None
def c2pyerror(err_msg):