diff --git a/364.patch b/364.patch new file mode 100644 index 0000000..e17d4c9 --- /dev/null +++ b/364.patch @@ -0,0 +1,33 @@ +From 0fd5649d6f971e5c19ac7f6953e9d6737d3fbb0b Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Petr=20Van=C4=9Bk?= +Date: Mon, 10 Jun 2024 13:22:24 +0200 +Subject: [PATCH] Add buffer and fileno for mocked sys.stdout + +This change fixes the issue of two failing tests because the sys.stdout +seems not to be properly mocked. Both tests need a buffer and test_piped +additionally needs fileno method. +--- + qrcode/tests/test_script.py | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/qrcode/tests/test_script.py b/qrcode/tests/test_script.py +index 4ae4ccbc..96458e4c 100644 +--- a/qrcode/tests/test_script.py ++++ b/qrcode/tests/test_script.py +@@ -30,6 +30,8 @@ def test_isatty(self, mock_print_ascii): + @mock.patch("sys.stdout") + @unittest.skipIf(not Image, "Requires PIL") + def test_piped(self, mock_stdout): ++ mock_stdout.buffer = io.BytesIO() ++ mock_stdout.fileno = lambda: 999 + main(["testtext"]) + + @mock.patch("os.isatty", lambda *args: True) +@@ -61,6 +63,7 @@ def test_optimize(self, mock_print_ascii): + + @mock.patch("sys.stdout") + def test_factory(self, mock_stdout): ++ mock_stdout.buffer = io.BytesIO() + main("testtext --factory svg".split()) + + @mock.patch("sys.stderr") diff --git a/python-qrcode.changes b/python-qrcode.changes index 98638d0..b4cca53 100644 --- a/python-qrcode.changes +++ b/python-qrcode.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Wed Jun 12 12:06:29 UTC 2024 - John Paul Adrian Glaubitz + +- Cherry-pick upstream patch to fix build with GCC 14 + * https://github.com/lincolnloop/python-qrcode/pull/364.patch + ------------------------------------------------------------------- Mon Feb 5 07:00:36 UTC 2024 - Steve Kowalik diff --git a/python-qrcode.spec b/python-qrcode.spec index 981beac..dc04e88 100644 --- a/python-qrcode.spec +++ b/python-qrcode.spec @@ -24,6 +24,8 @@ Summary: QR Code image generator License: BSD-3-Clause URL: https://github.com/lincolnloop/python-qrcode Source: https://files.pythonhosted.org/packages/source/q/qrcode/qrcode-%{version}.tar.gz +# PATCH-FIX-UPSTREAM - Add buffer and fileno for mocked sys.stdout +Patch: https://github.com/lincolnloop/python-qrcode/pull/364.patch BuildRequires: %{python_module Pillow} BuildRequires: %{python_module pip} BuildRequires: %{python_module pypng} @@ -48,6 +50,7 @@ of QR Codes. %prep %setup -q -n qrcode-%{version} +%patch -P0 -p1 # drop shebang from console_scripts sed -i '1s@^#!.*@@' qrcode/console_scripts.py