From 772fa6bda3a6244514d8a5d6637d43815d8f9a14 Mon Sep 17 00:00:00 2001 From: Tianqi Chen Date: Thu, 25 Feb 2021 09:53:41 -0500 Subject: [PATCH] [PYTHON] Enable proper error message in python package (#7521) --- python/tvm/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/python/tvm/__init__.py b/python/tvm/__init__.py index c2b4fdb2d00e..7a5f553ccdd5 100644 --- a/python/tvm/__init__.py +++ b/python/tvm/__init__.py @@ -68,6 +68,11 @@ from .contrib import rocm as _rocm, nvcc as _nvcc, sdaccel as _sdaccel +# NOTE: This file should be python2 compatible so we can +# raise proper error message when user run the package using +# an older version of the python + + def _should_print_backtrace(): in_pytest = "PYTEST_CURRENT_TEST" in os.environ tvm_backtrace = os.environ.get("TVM_BACKTRACE", "0") @@ -76,7 +81,7 @@ def _should_print_backtrace(): tvm_backtrace = bool(int(tvm_backtrace)) except ValueError: raise ValueError( - f"invalid value for TVM_BACKTRACE `{tvm_backtrace}`, please set to 0 or 1." + "invalid value for TVM_BACKTRACE {}, please set to 0 or 1.".format(tvm_backtrace) ) return in_pytest or tvm_backtrace