From 48c7731673565591f9184eacd574c21a7ebc356adae18396b17899c87a58a44e Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Tue, 4 Jul 2023 22:34:59 +0000 Subject: [PATCH 1/5] - Update to 1.1.2: - Changed handling of exceptions in exception group handler callbacks to not wrap a single exception in an exception group, as per CPython issue gh#python/cpython#103590. OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-exceptiongroup?expand=0&rev=13 --- exceptiongroup-1.1.1-gh.tar.gz | 3 --- exceptiongroup-1.1.2-gh.tar.gz | 3 +++ python-exceptiongroup.changes | 8 ++++++++ python-exceptiongroup.spec | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) delete mode 100644 exceptiongroup-1.1.1-gh.tar.gz create mode 100644 exceptiongroup-1.1.2-gh.tar.gz diff --git a/exceptiongroup-1.1.1-gh.tar.gz b/exceptiongroup-1.1.1-gh.tar.gz deleted file mode 100644 index 797410b..0000000 --- a/exceptiongroup-1.1.1-gh.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:abe42a62bac0948d95bba6a48f63d8ebb21a7420fd26039a4ec951873fafaee7 -size 23107 diff --git a/exceptiongroup-1.1.2-gh.tar.gz b/exceptiongroup-1.1.2-gh.tar.gz new file mode 100644 index 0000000..ace6af4 --- /dev/null +++ b/exceptiongroup-1.1.2-gh.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:107e769418fac86697c510aa0e6849ae48d384b20186ec4db5c23e567829589f +size 23079 diff --git a/python-exceptiongroup.changes b/python-exceptiongroup.changes index 9df41c3..b28d82a 100644 --- a/python-exceptiongroup.changes +++ b/python-exceptiongroup.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Tue Jul 4 22:32:27 UTC 2023 - Matej Cepl + +- Update to 1.1.2: + - Changed handling of exceptions in exception group handler + callbacks to not wrap a single exception in an exception + group, as per CPython issue gh#python/cpython#103590. + ------------------------------------------------------------------- Fri Apr 21 12:24:46 UTC 2023 - Dirk Müller diff --git a/python-exceptiongroup.spec b/python-exceptiongroup.spec index 8ff2dae..a36c97c 100644 --- a/python-exceptiongroup.spec +++ b/python-exceptiongroup.spec @@ -29,7 +29,7 @@ %{?sle15_python_module_pythons} Name: python-exceptiongroup%{psuffix} -Version: 1.1.1 +Version: 1.1.2 Release: 0 Summary: Backport of PEP 654 (exception groups) License: MIT AND Python-2.0 From 75be6364218ed3325cf76895c45d80af211aed5f6848a4b81c2013f4642879df Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Tue, 4 Jul 2023 23:39:40 +0000 Subject: [PATCH 2/5] - Add 64_handl_embed_excep.patch fixing gh#agronholm/exceptiongroup#64. OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-exceptiongroup?expand=0&rev=14 --- 64_handl_embed_excep.patch | 98 +++++++++++++++++++++++++++++++++++ python-exceptiongroup.changes | 2 + python-exceptiongroup.spec | 5 +- 3 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 64_handl_embed_excep.patch diff --git a/64_handl_embed_excep.patch b/64_handl_embed_excep.patch new file mode 100644 index 0000000..c24c947 --- /dev/null +++ b/64_handl_embed_excep.patch @@ -0,0 +1,98 @@ +From 821d5ebaadfd0b5b16c785a942f69e89933217bf Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Alex=20Gr=C3=B6nholm?= +Date: Mon, 3 Jul 2023 00:54:13 +0300 +Subject: [PATCH] Changed handling of a single exception raised in exception + group handlers to match Python 3.11.4 + +Fixes #64. +--- + CHANGES.rst | 6 ++++++ + src/exceptiongroup/_catch.py | 5 ++++- + tests/test_catch.py | 8 +------- + tests/test_catch_py311.py | 8 +------- + 4 files changed, 12 insertions(+), 15 deletions(-) + +diff --git a/CHANGES.rst b/CHANGES.rst +index 31831a3..3c2b08f 100644 +--- a/CHANGES.rst ++++ b/CHANGES.rst +@@ -3,6 +3,12 @@ Version history + + This library adheres to `Semantic Versioning 2.0 `_. + ++**UNRELEASED** ++ ++- Changed handling of exceptions in exception group handler callbacks to not wrap a ++ single exception in an exception group, as per ++ `CPython issue 103590 `_ ++ + **1.1.1** + + - Worked around +diff --git a/src/exceptiongroup/_catch.py b/src/exceptiongroup/_catch.py +index aa16d16..0be39b4 100644 +--- a/src/exceptiongroup/_catch.py ++++ b/src/exceptiongroup/_catch.py +@@ -37,7 +37,7 @@ def __exit__( + + return False + +- def handle_exception(self, exc: BaseException) -> BaseExceptionGroup | None: ++ def handle_exception(self, exc: BaseException) -> BaseException | None: + excgroup: BaseExceptionGroup | None + if isinstance(exc, BaseExceptionGroup): + excgroup = exc +@@ -57,6 +57,9 @@ def handle_exception(self, exc: BaseException) -> BaseExceptionGroup | None: + break + + if new_exceptions: ++ if len(new_exceptions) == 1: ++ return new_exceptions[0] ++ + if excgroup: + new_exceptions.append(excgroup) + +diff --git a/tests/test_catch.py b/tests/test_catch.py +index bc520b9..0af2fa0 100644 +--- a/tests/test_catch.py ++++ b/tests/test_catch.py +@@ -148,15 +148,9 @@ def test_catch_handler_raises(): + def handler(exc): + raise RuntimeError("new") + +- try: ++ with pytest.raises(RuntimeError, match="new"): + with catch({(ValueError, ValueError): handler}): + raise ExceptionGroup("booboo", [ValueError("bar")]) +- except ExceptionGroup as exc: +- assert exc.message == "" +- assert len(exc.exceptions) == 1 +- assert isinstance(exc.exceptions[0], RuntimeError) +- else: +- pytest.fail("Did not raise an ExceptionGroup") + + + def test_catch_subclass(): +diff --git a/tests/test_catch_py311.py b/tests/test_catch_py311.py +index cc161e7..4351be8 100644 +--- a/tests/test_catch_py311.py ++++ b/tests/test_catch_py311.py +@@ -122,17 +122,11 @@ def test_catch_full_match(): + + + def test_catch_handler_raises(): +- try: ++ with pytest.raises(RuntimeError, match="new"): + try: + raise ExceptionGroup("booboo", [ValueError("bar")]) + except* ValueError: + raise RuntimeError("new") +- except ExceptionGroup as exc: +- assert exc.message == "" +- assert len(exc.exceptions) == 1 +- assert isinstance(exc.exceptions[0], RuntimeError) +- else: +- pytest.fail("Did not raise an ExceptionGroup") + + + def test_catch_subclass(): diff --git a/python-exceptiongroup.changes b/python-exceptiongroup.changes index b28d82a..50e3b45 100644 --- a/python-exceptiongroup.changes +++ b/python-exceptiongroup.changes @@ -5,6 +5,8 @@ Tue Jul 4 22:32:27 UTC 2023 - Matej Cepl - Changed handling of exceptions in exception group handler callbacks to not wrap a single exception in an exception group, as per CPython issue gh#python/cpython#103590. +- Add 64_handl_embed_excep.patch fixing + gh#agronholm/exceptiongroup#64. ------------------------------------------------------------------- Fri Apr 21 12:24:46 UTC 2023 - Dirk Müller diff --git a/python-exceptiongroup.spec b/python-exceptiongroup.spec index a36c97c..dfe5128 100644 --- a/python-exceptiongroup.spec +++ b/python-exceptiongroup.spec @@ -35,6 +35,9 @@ Summary: Backport of PEP 654 (exception groups) License: MIT AND Python-2.0 URL: https://github.com/agronholm/exceptiongroup Source: https://github.com/agronholm/exceptiongroup/archive/refs/tags/%{version}.tar.gz#/exceptiongroup-%{version}-gh.tar.gz +# PATCH-FIX-UPSTREAM 64_handl_embed_excep.patch gh#agronholm/exceptiongroup#64 mcepl@suse.com +# Changed handling of a single exception raised in exception +Patch0: 64_handl_embed_excep.patch BuildRequires: %{python_module base >= 3.7} BuildRequires: %{python_module flit-scm} BuildRequires: %{python_module pip} @@ -75,7 +78,7 @@ exception group classes are used instead, ``TracebackException`` is not monkey p and the exception hook won't be installed. %prep -%setup -q -n exceptiongroup-%{version} +%autosetup -p1 -n exceptiongroup-%{version} %if !%{with test} %build From 48c9f9aa16fb2711b5ed4532200f22e3b8ba03f7ff9c5767af615ea9bb7d68a6 Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Tue, 4 Jul 2023 23:45:07 +0000 Subject: [PATCH 3/5] REmove unnecessary patch. OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-exceptiongroup?expand=0&rev=15 --- 64_handl_embed_excep.patch | 98 ----------------------------------- python-exceptiongroup.changes | 2 - python-exceptiongroup.spec | 3 -- 3 files changed, 103 deletions(-) delete mode 100644 64_handl_embed_excep.patch diff --git a/64_handl_embed_excep.patch b/64_handl_embed_excep.patch deleted file mode 100644 index c24c947..0000000 --- a/64_handl_embed_excep.patch +++ /dev/null @@ -1,98 +0,0 @@ -From 821d5ebaadfd0b5b16c785a942f69e89933217bf Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Alex=20Gr=C3=B6nholm?= -Date: Mon, 3 Jul 2023 00:54:13 +0300 -Subject: [PATCH] Changed handling of a single exception raised in exception - group handlers to match Python 3.11.4 - -Fixes #64. ---- - CHANGES.rst | 6 ++++++ - src/exceptiongroup/_catch.py | 5 ++++- - tests/test_catch.py | 8 +------- - tests/test_catch_py311.py | 8 +------- - 4 files changed, 12 insertions(+), 15 deletions(-) - -diff --git a/CHANGES.rst b/CHANGES.rst -index 31831a3..3c2b08f 100644 ---- a/CHANGES.rst -+++ b/CHANGES.rst -@@ -3,6 +3,12 @@ Version history - - This library adheres to `Semantic Versioning 2.0 `_. - -+**UNRELEASED** -+ -+- Changed handling of exceptions in exception group handler callbacks to not wrap a -+ single exception in an exception group, as per -+ `CPython issue 103590 `_ -+ - **1.1.1** - - - Worked around -diff --git a/src/exceptiongroup/_catch.py b/src/exceptiongroup/_catch.py -index aa16d16..0be39b4 100644 ---- a/src/exceptiongroup/_catch.py -+++ b/src/exceptiongroup/_catch.py -@@ -37,7 +37,7 @@ def __exit__( - - return False - -- def handle_exception(self, exc: BaseException) -> BaseExceptionGroup | None: -+ def handle_exception(self, exc: BaseException) -> BaseException | None: - excgroup: BaseExceptionGroup | None - if isinstance(exc, BaseExceptionGroup): - excgroup = exc -@@ -57,6 +57,9 @@ def handle_exception(self, exc: BaseException) -> BaseExceptionGroup | None: - break - - if new_exceptions: -+ if len(new_exceptions) == 1: -+ return new_exceptions[0] -+ - if excgroup: - new_exceptions.append(excgroup) - -diff --git a/tests/test_catch.py b/tests/test_catch.py -index bc520b9..0af2fa0 100644 ---- a/tests/test_catch.py -+++ b/tests/test_catch.py -@@ -148,15 +148,9 @@ def test_catch_handler_raises(): - def handler(exc): - raise RuntimeError("new") - -- try: -+ with pytest.raises(RuntimeError, match="new"): - with catch({(ValueError, ValueError): handler}): - raise ExceptionGroup("booboo", [ValueError("bar")]) -- except ExceptionGroup as exc: -- assert exc.message == "" -- assert len(exc.exceptions) == 1 -- assert isinstance(exc.exceptions[0], RuntimeError) -- else: -- pytest.fail("Did not raise an ExceptionGroup") - - - def test_catch_subclass(): -diff --git a/tests/test_catch_py311.py b/tests/test_catch_py311.py -index cc161e7..4351be8 100644 ---- a/tests/test_catch_py311.py -+++ b/tests/test_catch_py311.py -@@ -122,17 +122,11 @@ def test_catch_full_match(): - - - def test_catch_handler_raises(): -- try: -+ with pytest.raises(RuntimeError, match="new"): - try: - raise ExceptionGroup("booboo", [ValueError("bar")]) - except* ValueError: - raise RuntimeError("new") -- except ExceptionGroup as exc: -- assert exc.message == "" -- assert len(exc.exceptions) == 1 -- assert isinstance(exc.exceptions[0], RuntimeError) -- else: -- pytest.fail("Did not raise an ExceptionGroup") - - - def test_catch_subclass(): diff --git a/python-exceptiongroup.changes b/python-exceptiongroup.changes index 50e3b45..b28d82a 100644 --- a/python-exceptiongroup.changes +++ b/python-exceptiongroup.changes @@ -5,8 +5,6 @@ Tue Jul 4 22:32:27 UTC 2023 - Matej Cepl - Changed handling of exceptions in exception group handler callbacks to not wrap a single exception in an exception group, as per CPython issue gh#python/cpython#103590. -- Add 64_handl_embed_excep.patch fixing - gh#agronholm/exceptiongroup#64. ------------------------------------------------------------------- Fri Apr 21 12:24:46 UTC 2023 - Dirk Müller diff --git a/python-exceptiongroup.spec b/python-exceptiongroup.spec index dfe5128..402bdce 100644 --- a/python-exceptiongroup.spec +++ b/python-exceptiongroup.spec @@ -35,9 +35,6 @@ Summary: Backport of PEP 654 (exception groups) License: MIT AND Python-2.0 URL: https://github.com/agronholm/exceptiongroup Source: https://github.com/agronholm/exceptiongroup/archive/refs/tags/%{version}.tar.gz#/exceptiongroup-%{version}-gh.tar.gz -# PATCH-FIX-UPSTREAM 64_handl_embed_excep.patch gh#agronholm/exceptiongroup#64 mcepl@suse.com -# Changed handling of a single exception raised in exception -Patch0: 64_handl_embed_excep.patch BuildRequires: %{python_module base >= 3.7} BuildRequires: %{python_module flit-scm} BuildRequires: %{python_module pip} From 1c894e8e0f92f79ff8f2ad01cc14496e271a11c3a7d4d45cdedf514fb119775e Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Wed, 5 Jul 2023 05:29:00 +0000 Subject: [PATCH 4/5] - Skip still failing test_catch_handler_raises (gh#agronholm/exceptiongroup#64). OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-exceptiongroup?expand=0&rev=16 --- python-exceptiongroup.changes | 2 ++ python-exceptiongroup.spec | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/python-exceptiongroup.changes b/python-exceptiongroup.changes index b28d82a..ef5f3e6 100644 --- a/python-exceptiongroup.changes +++ b/python-exceptiongroup.changes @@ -5,6 +5,8 @@ Tue Jul 4 22:32:27 UTC 2023 - Matej Cepl - Changed handling of exceptions in exception group handler callbacks to not wrap a single exception in an exception group, as per CPython issue gh#python/cpython#103590. +- Skip still failing test_catch_handler_raises + (gh#agronholm/exceptiongroup#64). ------------------------------------------------------------------- Fri Apr 21 12:24:46 UTC 2023 - Dirk Müller diff --git a/python-exceptiongroup.spec b/python-exceptiongroup.spec index 402bdce..4fc7441 100644 --- a/python-exceptiongroup.spec +++ b/python-exceptiongroup.spec @@ -89,7 +89,8 @@ export SETUPTOOLS_SCM_PRETEND_VERSION=%{version} %if %{with test} %check -%pytest +# gh#agronholm/exceptiongroup#64 +%pytest -k 'not test_catch_handler_raises' %endif %if !%{with test} From 1b0987a52d89a76cd4ebc3fcfcac7278f56a3aad2edf51d771b9656d71169068 Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Wed, 5 Jul 2023 10:24:03 +0000 Subject: [PATCH 5/5] - Add skip-test_catch_handler_raises-for-older-311.patch OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-exceptiongroup?expand=0&rev=17 --- python-exceptiongroup.changes | 2 +- python-exceptiongroup.spec | 6 ++-- ...t_catch_handler_raises-for-older-311.patch | 31 +++++++++++++++++++ 3 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 skip-test_catch_handler_raises-for-older-311.patch diff --git a/python-exceptiongroup.changes b/python-exceptiongroup.changes index ef5f3e6..0484fec 100644 --- a/python-exceptiongroup.changes +++ b/python-exceptiongroup.changes @@ -5,7 +5,7 @@ Tue Jul 4 22:32:27 UTC 2023 - Matej Cepl - Changed handling of exceptions in exception group handler callbacks to not wrap a single exception in an exception group, as per CPython issue gh#python/cpython#103590. -- Skip still failing test_catch_handler_raises +- Add skip-test_catch_handler_raises-for-older-311.patch (gh#agronholm/exceptiongroup#64). ------------------------------------------------------------------- diff --git a/python-exceptiongroup.spec b/python-exceptiongroup.spec index 4fc7441..836ea59 100644 --- a/python-exceptiongroup.spec +++ b/python-exceptiongroup.spec @@ -35,6 +35,9 @@ Summary: Backport of PEP 654 (exception groups) License: MIT AND Python-2.0 URL: https://github.com/agronholm/exceptiongroup Source: https://github.com/agronholm/exceptiongroup/archive/refs/tags/%{version}.tar.gz#/exceptiongroup-%{version}-gh.tar.gz +# PATCH-FIX-UPSTREAM skip-test_catch_handler_raises-for-older-311.patch gh#agronholm/exceptiongroup#64 mcepl@suse.com +# Skip test_catch_handler_raises() on Python 3.11 if the Python version is less than 3.11.4 +Patch0: skip-test_catch_handler_raises-for-older-311.patch BuildRequires: %{python_module base >= 3.7} BuildRequires: %{python_module flit-scm} BuildRequires: %{python_module pip} @@ -89,8 +92,7 @@ export SETUPTOOLS_SCM_PRETEND_VERSION=%{version} %if %{with test} %check -# gh#agronholm/exceptiongroup#64 -%pytest -k 'not test_catch_handler_raises' +%pytest %endif %if !%{with test} diff --git a/skip-test_catch_handler_raises-for-older-311.patch b/skip-test_catch_handler_raises-for-older-311.patch new file mode 100644 index 0000000..754d8ae --- /dev/null +++ b/skip-test_catch_handler_raises-for-older-311.patch @@ -0,0 +1,31 @@ +From 452ba0946347b4e0df950763213f162704bc1eed Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Alex=20Gr=C3=B6nholm?= +Date: Wed, 5 Jul 2023 12:28:15 +0300 +Subject: [PATCH] Skip test_catch_handler_raises() on Python 3.11 if the Python + version is too low + +--- + tests/test_catch_py311.py | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/tests/test_catch_py311.py b/tests/test_catch_py311.py +index 4351be8..5880f0a 100644 +--- a/tests/test_catch_py311.py ++++ b/tests/test_catch_py311.py +@@ -1,3 +1,5 @@ ++import sys ++ + import pytest + + from exceptiongroup import ExceptionGroup +@@ -121,6 +123,10 @@ def test_catch_full_match(): + pass + + ++@pytest.mark.skipif( ++ sys.version_info < (3, 11, 4), ++ reason="Behavior was changed in 3.11.4", ++) + def test_catch_handler_raises(): + with pytest.raises(RuntimeError, match="new"): + try: