diff options
authorRelease Manager <>2018-04-17 00:35:39 +0200
committerVolker Braun <>2018-04-17 00:35:39 +0200
commit8fc1b6ad67c1a39aeb9aa52bfd6c4288edee0ab0 (patch)
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: Reported by: jdemeyer Ticket author(s): Jeroen Demeyer Reviewer(s): Nils Bruin
1 files changed, 6 insertions, 1 deletions
diff --git a/src/sage/misc/ b/src/sage/misc/
index 2ac668a..0d4660f 100644
--- a/src/sage/misc/
+++ b/src/sage/misc/
@@ -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:
- 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):