summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRelease Manager <release@sagemath.org>2018-04-17 00:35:39 +0200
committerVolker Braun <vbraun.name@gmail.com>2018-04-17 00:35:39 +0200
commit8fc1b6ad67c1a39aeb9aa52bfd6c4288edee0ab0 (patch)
tree789203538b5d213da42c034e91a82e3bceca5a4d
parentTrac #25078: ./sage -f sagelib no longer works (diff)
parentIn cython(), redirect file descriptor 2 instead of sys.stderr (diff)
Trac #25177: cython() does not work in Jupyter
When `sys.stderr` is not a file but some other stream, `cython()` breaks because of this redirection: {{{ with redirection(sys.stderr, errfile, close=False): dist.run_command("build") }}} The goal is to redirect the actual OS-level stderr, so we should just use the file descriptor number `2` instead. URL: https://trac.sagemath.org/25177 Reported by: jdemeyer Ticket author(s): Jeroen Demeyer Reviewer(s): Nils Bruin
-rw-r--r--src/sage/misc/cython.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/sage/misc/cython.py b/src/sage/misc/cython.py
index 2ac668a..0d4660f 100644
--- a/src/sage/misc/cython.py
+++ b/src/sage/misc/cython.py
@@ -661,7 +661,12 @@ def cython(filename, verbose=0, compile_message=False,
# Capture errors from distutils and its child processes
with open(os.path.join(target_dir, name + ".err"), 'w+') as errfile:
try:
- with redirection(sys.stderr, errfile, close=False):
+ # Redirect stderr to errfile. We use the file descriptor
+ # number "2" instead of "sys.stderr" because we really
+ # want to redirect the messages from GCC. These are sent
+ # to the actual stderr, regardless of what sys.stderr is.
+ sys.stderr.flush()
+ with redirection(2, errfile, close=False):
dist.run_command("build")
finally:
errfile.seek(0)