summaryrefslogtreecommitdiff
path: root/dev-python/cython/files/cython-3.0.0-version-stderr-stdout.patch
diff options
context:
space:
mode:
Diffstat (limited to 'dev-python/cython/files/cython-3.0.0-version-stderr-stdout.patch')
-rw-r--r--dev-python/cython/files/cython-3.0.0-version-stderr-stdout.patch35
1 files changed, 35 insertions, 0 deletions
diff --git a/dev-python/cython/files/cython-3.0.0-version-stderr-stdout.patch b/dev-python/cython/files/cython-3.0.0-version-stderr-stdout.patch
new file mode 100644
index 000000000000..7a12c6eead53
--- /dev/null
+++ b/dev-python/cython/files/cython-3.0.0-version-stderr-stdout.patch
@@ -0,0 +1,35 @@
+https://bugs.gentoo.org/911333
+https://github.com/cython/cython/pull/5572
+https://github.com/cython/cython/commit/ca69b359b040bf6c0fc90692bbea3bdd9d7877e6
+
+From ca69b359b040bf6c0fc90692bbea3bdd9d7877e6 Mon Sep 17 00:00:00 2001
+From: Eli Schwartz <eschwartz@archlinux.org>
+Date: Fri, 28 Jul 2023 06:52:03 -0400
+Subject: [PATCH] Only write the version to stderr, if it's a separate file
+ descriptor from stdout (GH-5572)
+
+At least one project tries to detect the Cython version by redirecting stderr to
+stdout and capturing it. This is done in pure POSIX shell, so it probably seemed
+like the simple and obvious solution for a less capable programming language
+given that no output at all was expected on stdout.
+
+But the result is that the version number appears twice, and then gets misparsed
+and ends up triggering bad assumptions in the code running cython.
+
+It turns out that it's pretty easy to just print once, though. Detect when
+stdout and stderr are redirected to the same location, and only print once.
+
+See https://github.com/cython/cython/issues/5504
+Fixes https://bugs.gentoo.org/911333
+--- a/Cython/Compiler/Main.py
++++ b/Cython/Compiler/Main.py
+@@ -776,7 +776,7 @@ def main(command_line = 0):
+ print("Cython version %s" % __version__)
+ # For legacy reasons, we also write the version to stderr.
+ # New tools should expect it in stdout, but existing ones still pipe from stderr.
+- if not sys.stderr.isatty():
++ if not sys.stderr.isatty() and os.fstat(1) != os.fstat(2):
+ sys.stderr.write("Cython version %s\n" % __version__)
+ if options.working_path!="":
+ os.chdir(options.working_path)
+