未验证 提交 18284261 编写于 作者: J jiangcheng 提交者: GitHub

solve ANSI escape sequences print error in cmd and powershell (#33689)

上级 2b6fc108
......@@ -16,6 +16,7 @@ import inspect
import numpy as np
import warnings
import weakref
import sys
import paddle
from .. import framework
......@@ -372,6 +373,9 @@ def monkey_patch_varbase():
"""
msg = "tensor.grad will return the tensor value of the gradient."
warning_msg = "\033[93m\nWarning:\n%s \033[0m" % (msg)
# ensure ANSI escape sequences print correctly in cmd and powershell
if sys.platform.lower() == 'win32':
warning_msg = "\nWarning:\n%s " % (msg)
warnings.warn(warning_msg)
return self._grad_ivar()
......
......@@ -18,6 +18,7 @@ decorator to deprecate a function or class
import warnings
import functools
import paddle
import sys
__all__ = []
......@@ -99,6 +100,10 @@ def deprecated(update_to="", since="", reason="", level=0):
func.__module__, func.__name__))
warningmsg = "\033[93m\nWarning:\n%s \033[0m" % (msg)
# ensure ANSI escape sequences print correctly in cmd and powershell
if sys.platform.lower() == 'win32':
warningmsg = "\nWarning:\n%s " % (msg)
v_current = [int(i) for i in paddle.__version__.split(".")]
v_current += [0] * (4 - len(v_current))
v_since = [int(i) for i in _since.split(".")]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册