From: Renaud Barate Date: Tue, 8 Jul 2014 14:48:00 +0000 (+0200) Subject: Fix bug with Python warning messages not redirected when sys.stderr is redirected X-Git-Tag: V7_5_0a1~21 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f0b0cbc96c26d06877d83ba4e53e09a2cbda3899;p=modules%2Fkernel.git Fix bug with Python warning messages not redirected when sys.stderr is redirected --- diff --git a/src/KERNEL_PY/kernel/deprecation.py b/src/KERNEL_PY/kernel/deprecation.py index 588b41625..ebd1b3002 100644 --- a/src/KERNEL_PY/kernel/deprecation.py +++ b/src/KERNEL_PY/kernel/deprecation.py @@ -149,7 +149,9 @@ def is_called_by_sphinx(): def __show_colored_warning(message, category, filename, - lineno, file = sys.stderr, line = None): + lineno, file = None, line = None): + if file is None: + file = sys.stderr str = warnings.formatwarning(message, category, filename, lineno, line) if category == DeprecationWarning and termcolor.canDisplayColor(file): file.write(termcolor.makeColoredMessage(str, termcolor.BLUE))