15
0

- Add createElement.patch to fix tests with fixed python interpreters

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-Twisted?expand=0&rev=166
This commit is contained in:
2025-12-29 10:05:19 +00:00
committed by Git OBS Bridge
commit 74f4059fa8
15 changed files with 2318 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
.osc

View File

@@ -0,0 +1,64 @@
From 7130df7ee21ebd93d7e15e7c4ef752b759f8e1c3 Mon Sep 17 00:00:00 2001
From: Thomas Grainger <tagrain@gmail.com>
Date: Sun, 21 Feb 2021 11:54:25 +0000
Subject: [PATCH] delegate to stdlib parse qs
---
src/twisted/web/http.py | 29 +---------------------
src/twisted/web/newsfragments/10096.bugfix | 1 +
2 files changed, 2 insertions(+), 28 deletions(-)
create mode 100644 src/twisted/web/newsfragments/10096.bugfix
Index: twisted-24.10.0/src/twisted/web/http.py
===================================================================
--- twisted-24.10.0.orig/src/twisted/web/http.py
+++ twisted-24.10.0/src/twisted/web/http.py
@@ -125,6 +125,7 @@ from urllib.parse import (
ParseResultBytes,
unquote_to_bytes as unquote,
urlparse as _urlparse,
+ parse_qs,
)
from zope.interface import Attribute, Interface, implementer, provider
@@ -371,34 +372,6 @@ def urlparse(url):
return ParseResultBytes(scheme, netloc, path, params, query, fragment)
-def parse_qs(qs, keep_blank_values=0, strict_parsing=0):
- """
- Like C{cgi.parse_qs}, but with support for parsing byte strings on Python 3.
-
- This was created to help with Python 2 to Python 3 migration.
- Consider using L{urllib.parse.parse_qs}.
-
- @type qs: C{bytes}
- """
- d = {}
- items = [s2 for s1 in qs.split(b"&") for s2 in s1.split(b";")]
- for item in items:
- try:
- k, v = item.split(b"=", 1)
- except ValueError:
- if strict_parsing:
- raise
- continue
- if v or keep_blank_values:
- k = unquote(k.replace(b"+", b" "))
- v = unquote(v.replace(b"+", b" "))
- if k in d:
- d[k].append(v)
- else:
- d[k] = [v]
- return d
-
-
def datetimeToString(msSinceEpoch=None):
"""
Convert seconds since epoch to HTTP datetime string.
Index: twisted-24.10.0/src/twisted/web/newsfragments/10096.bugfix
===================================================================
--- /dev/null
+++ twisted-24.10.0/src/twisted/web/newsfragments/10096.bugfix
@@ -0,0 +1 @@
+delegate to urllib.parse:parse_qs in twisted.web.http:parse_qs to avoid CVE-2021-23336 and the associated CI failures

3
_multibuild Normal file
View File

@@ -0,0 +1,3 @@
<multibuild>
<package>test</package>
</multibuild>

37
createElement.patch Normal file
View File

@@ -0,0 +1,37 @@
From b035f4a1a952c93445a01f2e17df88689ddf9bdf Mon Sep 17 00:00:00 2001
From: Glyph <code@glyph.im>
Date: Wed, 10 Dec 2025 01:10:32 -0800
Subject: [PATCH] use createElement in the test rather than instantiating
Element
---
src/twisted/newsfragments/12549.misc | 0
src/twisted/web/test/test_domhelpers.py | 6 +++---
2 files changed, 3 insertions(+), 3 deletions(-)
create mode 100644 src/twisted/newsfragments/12549.misc
diff --git a/src/twisted/newsfragments/12549.misc b/src/twisted/newsfragments/12549.misc
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/src/twisted/web/test/test_domhelpers.py b/src/twisted/web/test/test_domhelpers.py
index bbefd68516b..d28b89f30e8 100644
--- a/src/twisted/web/test/test_domhelpers.py
+++ b/src/twisted/web/test/test_domhelpers.py
@@ -109,14 +109,14 @@ def test_clearNode(self):
doc1 = self.dom.parseString("<a><b><c><d/></c></b></a>")
a_node = doc1.documentElement
domhelpers.clearNode(a_node)
- self.assertEqual(a_node.toxml(), self.dom.Element("a").toxml())
+ self.assertEqual(a_node.toxml(), doc1.createElement("a").toxml())
doc2 = self.dom.parseString("<a><b><c><d/></c></b></a>")
b_node = doc2.documentElement.childNodes[0]
domhelpers.clearNode(b_node)
actual = doc2.documentElement.toxml()
- expected = self.dom.Element("a")
- expected.appendChild(self.dom.Element("b"))
+ expected = doc2.createElement("a")
+ expected.appendChild(doc2.createElement("b"))
self.assertEqual(actual, expected.toxml())
def test_get(self):

View File

@@ -0,0 +1,14 @@
diff --git a/src/twisted/test/test_failure.py b/src/twisted/test/test_failure.py
index a9e920c10e..de9c499972 100644
--- a/src/twisted/test/test_failure.py
+++ b/src/twisted/test/test_failure.py
@@ -19,7 +19,8 @@ from types import TracebackType
from typing import Any, Generator, cast
from unittest import skipIf
-from cython_test_exception_raiser import raiser
+# from cython_test_exception_raiser import raiser
+raiser = None
from twisted.python import failure, reflect
from twisted.trial.unittest import SynchronousTestCase

View File

@@ -0,0 +1,25 @@
---
src/twisted/conch/test/test_keys.py | 3 +++
1 file changed, 3 insertions(+)
Index: twisted-24.10.0/src/twisted/conch/test/test_keys.py
===================================================================
--- twisted-24.10.0.orig/src/twisted/conch/test/test_keys.py
+++ twisted-24.10.0/src/twisted/conch/test/test_keys.py
@@ -15,6 +15,7 @@ from twisted.python import randbytes
from twisted.python.filepath import FilePath
from twisted.python.reflect import requireModule
from twisted.trial import unittest
+import unittest as pyunit
cryptography = requireModule("cryptography")
if cryptography is None:
@@ -278,6 +279,8 @@ class KeyTests(unittest.TestCase):
publicKey = keys.Key.fromString(public)
self.assertTrue(publicKey._sk)
+ @pyunit.skip('Upstream ticket https://twistedmatrix.com/trac/ticket/9665' +
+ ' has still not been resolved.')
def test_fromOpenSSH(self):
"""
Test that keys are correctly generated from OpenSSH strings.

50
py314.patch Normal file
View File

@@ -0,0 +1,50 @@
Index: twisted-25.5.0/src/twisted/internet/asyncioreactor.py
===================================================================
--- twisted-25.5.0.orig/src/twisted/internet/asyncioreactor.py
+++ twisted-25.5.0/src/twisted/internet/asyncioreactor.py
@@ -9,7 +9,7 @@ asyncio-based reactor implementation.
import errno
import sys
-from asyncio import AbstractEventLoop, get_event_loop
+from asyncio import AbstractEventLoop, get_running_loop, new_event_loop, set_event_loop
from typing import Dict, Optional, Type
from zope.interface import implementer
@@ -47,7 +47,11 @@ class AsyncioSelectorReactor(PosixReacto
def __init__(self, eventloop: Optional[AbstractEventLoop] = None):
if eventloop is None:
- _eventloop: AbstractEventLoop = get_event_loop()
+ try:
+ _eventloop: AbstractEventLoop = get_running_loop()
+ except RuntimeError:
+ _eventloop: AbstractEventLoop = new_event_loop()
+ set_event_loop(_eventloop)
else:
_eventloop = eventloop
Index: twisted-25.5.0/src/twisted/web/test/test_webclient.py
===================================================================
--- twisted-25.5.0.orig/src/twisted/web/test/test_webclient.py
+++ twisted-25.5.0/src/twisted/web/test/test_webclient.py
@@ -5,7 +5,8 @@
Tests L{twisted.web.client} helper APIs
"""
-
+import sys
+from unittest import SkipTest
from urllib.parse import urlparse
from twisted.trial import unittest
@@ -23,6 +24,9 @@ class URLJoinTests(unittest.TestCase):
resulting URL if neither the base nor the new path include a fragment
identifier.
"""
+ if sys.version_info[1] == 14:
+ raise SkipTest("https://github.com/twisted/twisted/issues/12427")
+
self.assertEqual(
client._urljoin(b"http://foo.com/bar", b"/quux"), b"http://foo.com/quux"
)

1724
python-Twisted.changes Normal file

File diff suppressed because it is too large Load Diff

2
python-Twisted.rpmlintrc Normal file
View File

@@ -0,0 +1,2 @@
# rpmlint is too stupid for the . in the name
addFilter("python-.*-require .*zope.interface")

329
python-Twisted.spec Normal file
View File

@@ -0,0 +1,329 @@
#
# spec file for package python-Twisted
#
# Copyright (c) 2025 SUSE LLC and contributors
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%global flavor @BUILD_FLAVOR@%{nil}
%if "%{flavor}" == "test"
%define psuffix -test
%bcond_without test
%else
%define psuffix %{nil}
%bcond_with test
%endif
%if 0%{?suse_version} > 1500
%bcond_without libalternatives
%else
%bcond_with libalternatives
%endif
%{?sle15_python_module_pythons}
Name: python-Twisted%{psuffix}
Version: 25.5.0
Release: 0
Summary: An asynchronous networking framework written in Python
License: MIT
URL: https://twisted.org
Source0: https://files.pythonhosted.org/packages/source/t/twisted/twisted-%{version}.tar.gz
Source99: python-Twisted.rpmlintrc
Patch0: skip_MultiCast.patch
# PATCH-FIX-UPSTREAM no-test_successResultOfWithFailureHasTraceback.patch https://twistedmatrix.com/trac/ticket/9665 mcepl@suse.com
# skip over the test test_successResultOfWithFailureHasTraceback
Patch2: no-test_successResultOfWithFailureHasTraceback.patch
# PATCH-FIX-UPSTREAM 1521_delegate_parseqs_stdlib_bpo42967.patch https://twistedmatrix.com/trac/ticket/10096 mcepl@suse.com
# overcome incompatibility with the solution for bpo#42967.
Patch3: 1521_delegate_parseqs_stdlib_bpo42967.patch
# PATCH-FIX-OPENSUSE We don't want to package yet another module, and it is easily skippable
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 https://github.com/twisted/twisted/issues/12430 Add support for Python 3.14
Patch7: py314.patch
# PATCH-FIX-UPSTREAM https://github.com/twisted/twisted/pull/12551 use createElement in the test rather than instantiating Element
Patch8: createElement.patch
BuildRequires: %{python_module hatch-fancy-pypi-readme}
BuildRequires: %{python_module hatchling}
BuildRequires: %{python_module incremental >= 24.7.0}
BuildRequires: %{python_module pip}
BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module wheel}
BuildRequires: fdupes
BuildRequires: git-core
BuildRequires: python-rpm-macros
# twisted[tls] is so common, let's keep it tied to the main package for the time being.
Requires: python-Twisted-tls = %{version}
BuildArch: noarch
# SECTION install requires
Requires: python-Automat >= 0.8.0
Requires: python-attrs >= 19.2.0
Requires: python-constantly >= 15.1
Requires: python-hyperlink >= 17.1.1
Requires: python-incremental >= 24.7.0
Requires: python-typing_extensions >= 3.6.5
Requires: python-zope.interface >= 4.4.2
# /SECTION
%if %{with libalternatives}
BuildRequires: alts
Requires: alts
%else
Requires(post): update-alternatives
Requires(postun): update-alternatives
%endif
%if %{with test}
BuildRequires: %{python_module Twisted-all_non_platform = %{version}}
BuildRequires: %{python_module Twisted-conch_nacl = %{version}}
BuildRequires: %{python_module httpx}
BuildRequires: %{python_module hypothesis}
# declared nowhere but required to pass 8 tests with timezone checks
BuildRequires: %{python_module pytz}
%endif
%python_subpackages
%description
An extensible framework for Python programming, with special focus
on event-based network programming and multiprotocol integration.
%if 0%{?suse_version} > 1500
%package -n %{name}-doc
Summary: An asynchronous networking framework written in Python - Documentation
%description -n %{name}-doc
An extensible framework for Python programming, with special focus
on event-based network programming and multiprotocol integration.
This package contains the documentation for python-Twisted
%endif
%package tls
Summary: TLS support for Twisted
Requires: python-Twisted = %{version}
Requires: python-idna >= 2.4
Requires: python-pyOpenSSL >= 16.0.0
Requires: python-service_identity >= 18.1.0
%description tls
Twisted is an extensible framework for Python programming, with special focus
on event-based network programming and multiprotocol integration.
This metapackage is for the optional feature tls
%package conch
Summary: Conch for Twisted
Requires: python-Twisted = %{version}
Requires: python-appdirs >= 1.4.0
Requires: python-bcrypt >= 3.0.0
Requires: python-cryptography >= 2.6
%description conch
Twisted is an extensible framework for Python programming, with special focus
on event-based network programming and multiprotocol integration.
Twisted Conch: The Twisted Shell. Terminal emulation, SSHv2 and telnet.
%package conch_nacl
Summary: Conch w/ NaCl for Twisted
Requires: python-Twisted-conch = %{version}
%description conch_nacl
Twisted is an extensible framework for Python programming, with special focus
on event-based network programming and multiprotocol integration.
%package serial
Summary: Serial support for Twisted
Requires: python-Twisted = %{version}
Requires: python-pyserial >= 3.0
%description serial
Twisted is an extensible framework for Python programming, with special focus
on event-based network programming and multiprotocol integration.
This metapackage is for the optional feature serial
%package http2
Summary: HTTP/2 support for Twisted
Requires: python-Twisted = %{version}
Requires: python-h2 >= 3.0
Requires: python-priority >= 1.1.0
%description http2
Twisted is an extensible framework for Python programming, with special focus
on event-based network programming and multiprotocol integration.
This metapackage is for the optional feature http2
%package contextvars
Summary: Contextvars extra for Twisted
Requires: python-Twisted = %{version}
%description contextvars
Twisted is an extensible framework for Python programming, with special focus
on event-based network programming and multiprotocol integration.
This metapackage is for the optional dependency contextvars
%package all_non_platform
Summary: The all_non_platform dependency extra for Twisted
Requires: python-PyHamcrest >= 1.9.0
Requires: python-Twisted-conch = %{version}
Requires: python-Twisted-contextvars = %{version}
Requires: python-Twisted-http2 = %{version}
Requires: python-Twisted-serial = %{version}
Requires: python-Twisted-tls = %{version}
%description all_non_platform
Twisted is an extensible framework for Python programming, with special focus
on event-based network programming and multiprotocol integration.
This metapackage is for the optional dependency all_non_platform
%prep
%autosetup -p1 -n twisted-%{version}
sed -i '1{/env python/d}' src/twisted/mail/test/pop3testserver.py src/twisted/trial/test/scripttest.py
find src/twisted -name .gitignore -delete
find src/twisted -name '*.misc' -size 0 -delete
%if ! %{with test}
%build
%pyproject_wheel
# empty files
rm docs/{fun/Twisted.Quotes,_static/.placeholder,_templates/.placeholder}
%fdupes docs
%endif
%if ! %{with test}
%install
%pyproject_install
find %{buildroot} -regex '.*\.[ch]' -exec rm {} ";" # Remove leftover C sources
install -dm0755 %{buildroot}%{_mandir}/man1/
install -m0644 docs/*/man/*.1 %{buildroot}%{_mandir}/man1/ # Install man pages
find docs -type f -print0 | xargs -0 chmod a-x # Fix doc-file dependency by removing x flags
#sed -i "s/\r//" docs/core/howto/listings/udp/{MulticastClient,MulticastServer}.py
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%if 0%{?suse_version} > 1500
mkdir -p %{buildroot}%{_docdir}/%{name}-doc
cp -r docs/* %{buildroot}%{_docdir}/%{name}-doc
%fdupes %{buildroot}%{_docdir}/%{name}-doc
%endif
# Prepare for update-alternatives usage
for p in twistd cftp ckeygen conch pyhtmlizer tkconch trial ; do
%python_clone -a %{buildroot}%{_bindir}/$p
%python_clone -a %{buildroot}%{_mandir}/man1/$p.1
done
# mailmail is useful only on Python 2
rm %{buildroot}%{_bindir}/mailmail %{buildroot}%{_mandir}/man1/mailmail.1
# no manpage for twist yet:
%python_clone -a %{buildroot}%{_bindir}/twist
# group all the alternatives under one master
%python_group_libalternatives twistd cftp ckeygen conch pyhtmlizer tkconch trial twist
%endif
%if %{with test}
%check
export LANG=en_US.UTF-8
export PYTHONDONTWRITEBYTECODE=1
%{python_expand # provide flavored commands for testing
# (= python_flavored_alternatives from gh#openSUSE/python-rpm-macros#120, but sadly not available for non-TW)
mkdir -p build/bin/
for f in %{buildroot}%{_bindir}/*-%{$python_bin_suffix}; do
ln -s $f build/bin/$(basename ${f%%%%-%{$python_bin_suffix}})
done
}
export PATH=$PWD/build/bin/:$PATH
# Relax the crypto policies for the test-suite
export OPENSSL_SYSTEM_CIPHERS_OVERRIDE=xyz_nonexistent_file
export OPENSSL_CONF=''
%python_expand PYTHONPATH=%{buildroot}%{$python_sitelib} $python -m twisted.trial twisted
%endif
%pre
%python_libalternatives_reset_alternative twistd
# these were master alternatives until Dec 2020
for f in cftp ckeygen conch pyhtmlizer tkconch trial twist; do
%python_libalternatives_reset_alternative $f
done
%post
%if !%{with libalternatives}
# these were master alternatives until Dec 2020. Remove before the install as slave links
for f in cftp ckeygen conch pyhtmlizer tkconch trial twist; do
(update-alternatives --quiet --list $f 2>&1 >/dev/null) && update-alternatives --quiet --remove-all $f
done
%endif
%{python_install_alternative twistd cftp ckeygen conch pyhtmlizer tkconch trial twist
twistd.1 cftp.1 ckeygen.1 conch.1 pyhtmlizer.1 tkconch.1 trial.1}
%postun
%python_uninstall_alternative twistd
%if ! %{with test}
%files %{python_files tls}
%license LICENSE
%files %{python_files conch}
%license LICENSE
%files %{python_files conch_nacl}
%license LICENSE
%files %{python_files serial}
%license LICENSE
%files %{python_files http2}
%license LICENSE
%files %{python_files contextvars}
%license LICENSE
%files %{python_files all_non_platform}
%license LICENSE
%files %{python_files}
%license LICENSE
%doc NEWS.rst README.rst
%python_alternative %{_bindir}/conch
%python_alternative %{_bindir}/tkconch
%python_alternative %{_mandir}/man1/conch.1%{?ext_man}
%python_alternative %{_mandir}/man1/tkconch.1%{?ext_man}
%python_alternative %{_bindir}/twistd
%python_alternative %{_bindir}/cftp
%python_alternative %{_bindir}/ckeygen
%python_alternative %{_bindir}/pyhtmlizer
%python_alternative %{_bindir}/trial
%python_alternative %{_bindir}/twist
%python_alternative %{_mandir}/man1/twistd.1%{?ext_man}
%python_alternative %{_mandir}/man1/cftp.1%{?ext_man}
%python_alternative %{_mandir}/man1/ckeygen.1%{?ext_man}
%python_alternative %{_mandir}/man1/pyhtmlizer.1%{?ext_man}
%python_alternative %{_mandir}/man1/trial.1%{?ext_man}
%{python_sitelib}/twisted
%{python_sitelib}/twisted-%{version}*-info
%if 0%{?suse_version} > 1500
%files -n %{name}-doc
%doc %{_docdir}/%{name}-doc
%else
%doc docs/
%endif
%endif
%changelog

View File

@@ -0,0 +1,15 @@
Index: twisted-25.5.0/pyproject.toml
===================================================================
--- twisted-25.5.0.orig/pyproject.toml
+++ twisted-25.5.0/pyproject.toml
@@ -97,8 +97,8 @@ serial = [
]
http2 = [
- "h2 >= 3.2, < 5.0",
- "priority >= 1.1.0, < 2.0",
+ "h2 >= 3.2",
+ "priority >= 1.1.0",
]
websocket = [

25
skip_MultiCast.patch Normal file
View File

@@ -0,0 +1,25 @@
---
src/twisted/test/test_udp.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Index: twisted-25.5.0/src/twisted/test/test_udp.py
===================================================================
--- twisted-25.5.0.orig/src/twisted/test/test_udp.py
+++ twisted-25.5.0/src/twisted/test/test_udp.py
@@ -22,7 +22,7 @@ from socket import (
inet_pton,
socket,
)
-from unittest import skipIf
+from unittest import skipIf, SkipTest
from twisted.internet import defer, error, interfaces, protocol, reactor, udp
from twisted.internet.address import IPv4Address, IPv6Address
@@ -638,6 +638,7 @@ class MulticastTests(TestCase):
wrongAddressFamily: str = "::1"
def setUp(self):
+ raise SkipTest("Multicast networking doesn't work with OBS")
self.server = Server()
self.client = Client()
# multicast won't work if we listen over loopback, apparently

BIN
twisted-24.10.0.tar.gz LFS Normal file

Binary file not shown.

3
twisted-25.5.0.tar.gz Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:1deb272358cb6be1e3e8fc6f9c8b36f78eb0fa7c2233d2dbe11ec6fee04ea316
size 3545725