From f0b0cbc96c26d06877d83ba4e53e09a2cbda3899 Mon Sep 17 00:00:00 2001 From: Renaud Barate Date: Tue, 8 Jul 2014 16:48:00 +0200 Subject: [PATCH] Fix bug with Python warning messages not redirected when sys.stderr is redirected --- src/KERNEL_PY/kernel/deprecation.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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)) -- 2.39.2