From db51a8bbe54772c8e67ac596576a2abf9d47e3027bf7dc63ba94dd7f91afcfcb Mon Sep 17 00:00:00 2001 From: Steve Kowalik Date: Thu, 1 Feb 2024 08:34:36 +0000 Subject: [PATCH] - Add stop-using-3-arg-throw.patch: * Avoid 3-arg throw to fix a DeprecationWarning in Python 3.12. OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-Twisted?expand=0&rev=147 --- python-Twisted.changes | 6 ++++++ python-Twisted.spec | 6 ++++-- stop-using-3-arg-throw.patch | 37 ++++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 stop-using-3-arg-throw.patch diff --git a/python-Twisted.changes b/python-Twisted.changes index 1382496..9bd8c17 100644 --- a/python-Twisted.changes +++ b/python-Twisted.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Thu Feb 1 08:33:49 UTC 2024 - Steve Kowalik + +- Add stop-using-3-arg-throw.patch: + * Avoid 3-arg throw to fix a DeprecationWarning in Python 3.12. + ------------------------------------------------------------------- Thu Jan 18 21:33:05 UTC 2024 - Ben Greiner diff --git a/python-Twisted.spec b/python-Twisted.spec index edde216..4f81278 100644 --- a/python-Twisted.spec +++ b/python-Twisted.spec @@ -1,5 +1,5 @@ # -# spec file +# spec file for package python-Twisted # # Copyright (c) 2024 SUSE LLC # @@ -48,6 +48,8 @@ Patch4: twisted-pr12054-testinvokationpy3.12.1.patch Patch5: no-cython_test_exception_raiser.patch # PATCH-FIX-OPENSUSE remove-dependency-version-upper-bounds.patch boo#1190036 -- run with h2 >= 4.0.0 and priority >= 2.0 Patch6: remove-dependency-version-upper-bounds.patch +# PATCH-FIX-UPSTREAM gh#twisted/twisted#2280e5fcd0c9e9d34f5b7650c68f19c1498e49cd +Patch7: stop-using-3-arg-throw.patch BuildRequires: %{python_module hatch-fancy-pypi-readme} BuildRequires: %{python_module hatchling} BuildRequires: %{python_module incremental >= 21.3.0} @@ -58,7 +60,7 @@ BuildRequires: fdupes BuildRequires: git-core BuildRequires: python-rpm-macros Requires(post): update-alternatives -Requires(postun):update-alternatives +Requires(postun): update-alternatives # SECTION install requires Requires: python-Automat >= 0.8.0 Requires: python-attrs >= 19.2.0 diff --git a/stop-using-3-arg-throw.patch b/stop-using-3-arg-throw.patch new file mode 100644 index 0000000..00955eb --- /dev/null +++ b/stop-using-3-arg-throw.patch @@ -0,0 +1,37 @@ +From 2280e5fcd0c9e9d34f5b7650c68f19c1498e49cd Mon Sep 17 00:00:00 2001 +From: Adam Williamson +Date: Fri, 27 Oct 2023 16:56:24 -0700 +Subject: [PATCH] #12026 Adjust to deprecation of 3-arg generator.throw() + +In Python 3.12, the 3-arg signature of generator.throw() is +deprecated, you're only supposed to use the 1-arg signature +where you pass only an exception instance. I *think* this is the +right thing to pass in this case. + +Signed-off-by: Adam Williamson +--- + src/twisted/newsfragments/12026.bugfix | 1 + + src/twisted/python/failure.py | 2 +- + 2 files changed, 2 insertions(+), 1 deletion(-) + create mode 100644 src/twisted/newsfragments/12026.bugfix + +diff --git a/src/twisted/newsfragments/12026.bugfix b/src/twisted/newsfragments/12026.bugfix +new file mode 100644 +index 00000000000..4f06cf79a4a +--- /dev/null ++++ b/src/twisted/newsfragments/12026.bugfix +@@ -0,0 +1 @@ ++twisted.python.failure.Failure now throws exception for generators without triggering a deprecation warnings on Python 3.12. +diff --git a/src/twisted/python/failure.py b/src/twisted/python/failure.py +index ca893ca4c94..c006d555e55 100644 +--- a/src/twisted/python/failure.py ++++ b/src/twisted/python/failure.py +@@ -516,7 +516,7 @@ def throwExceptionIntoGenerator(self, g): + """ + # Note that the actual magic to find the traceback information + # is done in _findFailure. +- return g.throw(self.type, self.value, self.tb) ++ return g.throw(self.value.with_traceback(self.tb)) + + @classmethod + def _findFailure(cls):