1 |
commit: b98dada7f5fb8026d33d2743451e62af63240327 |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed May 27 10:07:25 2020 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed May 27 11:00:20 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b98dada7 |
7 |
|
8 |
dev-python/twisted: Fix 19.10.0 on py3.8 |
9 |
|
10 |
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org> |
11 |
|
12 |
.../twisted/files/twisted-19.10.0-py38.patch | 110 +++++++++++++++++++++ |
13 |
dev-python/twisted/twisted-19.10.0.ebuild | 8 +- |
14 |
2 files changed, 117 insertions(+), 1 deletion(-) |
15 |
|
16 |
diff --git a/dev-python/twisted/files/twisted-19.10.0-py38.patch b/dev-python/twisted/files/twisted-19.10.0-py38.patch |
17 |
new file mode 100644 |
18 |
index 00000000000..e787167d45b |
19 |
--- /dev/null |
20 |
+++ b/dev-python/twisted/files/twisted-19.10.0-py38.patch |
21 |
@@ -0,0 +1,110 @@ |
22 |
+From d33b90880b8eb024daa73bc3fd39aca0bc791ff1 Mon Sep 17 00:00:00 2001 |
23 |
+From: =?UTF-8?q?Lucas=20Treffenst=C3=A4dt?= <lucas@×××××××××××××.de> |
24 |
+Date: Mon, 13 Jan 2020 13:54:08 +0100 |
25 |
+Subject: [PATCH 1/2] CramMD5ClientAuthenticator now specifies the digestmod |
26 |
+ argument to hmac.HMAC constructor explicitly. |
27 |
+ |
28 |
+--- |
29 |
+ src/twisted/mail/_cred.py | 3 ++- |
30 |
+ 1 file changed, 2 insertions(+), 1 deletion(-) |
31 |
+ |
32 |
+diff --git a/src/twisted/mail/_cred.py b/src/twisted/mail/_cred.py |
33 |
+index 9d3646948..43c406f90 100644 |
34 |
+--- a/src/twisted/mail/_cred.py |
35 |
++++ b/src/twisted/mail/_cred.py |
36 |
+@@ -8,6 +8,7 @@ Credential managers for L{twisted.mail}. |
37 |
+ from __future__ import absolute_import, division |
38 |
+ |
39 |
+ import hmac |
40 |
++import hashlib |
41 |
+ |
42 |
+ from zope.interface import implementer |
43 |
+ |
44 |
+@@ -28,7 +29,7 @@ class CramMD5ClientAuthenticator: |
45 |
+ |
46 |
+ |
47 |
+ def challengeResponse(self, secret, chal): |
48 |
+- response = hmac.HMAC(secret, chal).hexdigest().encode('ascii') |
49 |
++ response = hmac.HMAC(secret, chal, digestmod = hashlib.md5).hexdigest().encode('ascii') |
50 |
+ return self.user + b' ' + response |
51 |
+ |
52 |
+ |
53 |
+-- |
54 |
+2.26.2 |
55 |
+ |
56 |
+From 694bc67f3cf7d36a6f512f0b76882e85d0966dd2 Mon Sep 17 00:00:00 2001 |
57 |
+From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Poisson?= <goffi@×××××.org> |
58 |
+Date: Sun, 17 Nov 2019 19:48:53 +0100 |
59 |
+Subject: [PATCH 2/2] Fix parsing of namespaced attributes with Python 3.8 in |
60 |
+ twisted.words.xish.domish.ExpatElementStream |
61 |
+ |
62 |
+--- |
63 |
+ src/twisted/words/newsfragments/9730.bugfix | 1 + |
64 |
+ src/twisted/words/test/test_domish.py | 17 +++++++++++++++++ |
65 |
+ src/twisted/words/xish/domish.py | 11 +++++++++-- |
66 |
+ 3 files changed, 27 insertions(+), 2 deletions(-) |
67 |
+ create mode 100644 src/twisted/words/newsfragments/9730.bugfix |
68 |
+ |
69 |
+diff --git a/src/twisted/words/newsfragments/9730.bugfix b/src/twisted/words/newsfragments/9730.bugfix |
70 |
+new file mode 100644 |
71 |
+index 000000000..5c91305c8 |
72 |
+--- /dev/null |
73 |
++++ b/src/twisted/words/newsfragments/9730.bugfix |
74 |
+@@ -0,0 +1 @@ |
75 |
++Fixed parsing of streams with Python 3.8 when there are spaces in namespaces or namespaced attributes in twisted.words.xish.domish.ExpatElementStream |
76 |
+diff --git a/src/twisted/words/test/test_domish.py b/src/twisted/words/test/test_domish.py |
77 |
+index a8f8fa76b..cd16e3a4d 100644 |
78 |
+--- a/src/twisted/words/test/test_domish.py |
79 |
++++ b/src/twisted/words/test/test_domish.py |
80 |
+@@ -350,6 +350,23 @@ class DomishStreamTestsMixin: |
81 |
+ self.elements[0].attributes, {(" bar baz ", "baz"): "quux"}) |
82 |
+ |
83 |
+ |
84 |
++ def test_attributesWithNamespaces(self): |
85 |
++ """ |
86 |
++ Attributes with namespace are parsed without Exception. |
87 |
++ (https://twistedmatrix.com/trac/ticket/9730 regression test) |
88 |
++ """ |
89 |
++ |
90 |
++ xml = b"""<root xmlns:test='http://example.org' xml:lang='en'> |
91 |
++ <test:test>test</test:test> |
92 |
++ </root>""" |
93 |
++ |
94 |
++ # with Python 3.8 and without #9730 fix, the following error would |
95 |
++ # happen at next line: |
96 |
++ # ``RuntimeError: dictionary keys changed during iteration`` |
97 |
++ self.stream.parse(xml) |
98 |
++ self.assertEqual(self.elements[0].uri, "http://example.org") |
99 |
++ |
100 |
++ |
101 |
+ def testChildPrefix(self): |
102 |
+ xml = b"<root xmlns='testns' xmlns:foo='testns2'><foo:child/></root>" |
103 |
+ |
104 |
+diff --git a/src/twisted/words/xish/domish.py b/src/twisted/words/xish/domish.py |
105 |
+index 2063c410a..fc49285f5 100644 |
106 |
+--- a/src/twisted/words/xish/domish.py |
107 |
++++ b/src/twisted/words/xish/domish.py |
108 |
+@@ -807,11 +807,18 @@ class ExpatElementStream: |
109 |
+ qname = ('', name) |
110 |
+ |
111 |
+ # Process attributes |
112 |
++ newAttrs = {} |
113 |
++ toDelete = [] |
114 |
+ for k, v in attrs.items(): |
115 |
+ if " " in k: |
116 |
+ aqname = k.rsplit(" ", 1) |
117 |
+- attrs[(aqname[0], aqname[1])] = v |
118 |
+- del attrs[k] |
119 |
++ newAttrs[(aqname[0], aqname[1])] = v |
120 |
++ toDelete.append(k) |
121 |
++ |
122 |
++ attrs.update(newAttrs) |
123 |
++ |
124 |
++ for k in toDelete: |
125 |
++ del attrs[k] |
126 |
+ |
127 |
+ # Construct the new element |
128 |
+ e = Element(qname, self.defaultNsStack[-1], attrs, self.localPrefixes) |
129 |
+-- |
130 |
+2.26.2 |
131 |
+ |
132 |
|
133 |
diff --git a/dev-python/twisted/twisted-19.10.0.ebuild b/dev-python/twisted/twisted-19.10.0.ebuild |
134 |
index 53a20c32ca0..46a5d0dbc96 100644 |
135 |
--- a/dev-python/twisted/twisted-19.10.0.ebuild |
136 |
+++ b/dev-python/twisted/twisted-19.10.0.ebuild |
137 |
@@ -17,6 +17,7 @@ HOMEPAGE="https://www.twistedmatrix.com/trac/" |
138 |
SRC_URI="https://twistedmatrix.com/Releases/${TWISTED_PN}" |
139 |
SRC_URI="${SRC_URI}/${TWISTED_RELEASE}/${TWISTED_P}.tar.bz2 |
140 |
https://dev.gentoo.org/~mgorny/dist/twisted-regen-cache.gz" |
141 |
+S=${WORKDIR}/${TWISTED_P} |
142 |
|
143 |
KEYWORDS="~alpha amd64 arm arm64 ~hppa ~ia64 ~mips ppc ppc64 s390 sparc x86 ~amd64-linux ~x86-linux" |
144 |
|
145 |
@@ -79,9 +80,14 @@ DEPEND=" |
146 |
) |
147 |
" |
148 |
|
149 |
-S=${WORKDIR}/${TWISTED_P} |
150 |
|
151 |
python_prepare_all() { |
152 |
+ local PATCHES=( |
153 |
+ "${FILESDIR}"/${P}-py38.patch |
154 |
+ "${FILESDIR}"/twisted-20.3.0-py38-cgi.patch |
155 |
+ "${FILESDIR}"/twisted-20.3.0-py38-hmac.patch |
156 |
+ ) |
157 |
+ |
158 |
# upstream test for making releases; not very useful and requires |
159 |
# sphinx (including on py2) |
160 |
rm src/twisted/python/test/test_release.py || die |