summaryrefslogtreecommitdiff
path: root/dev-python/twisted
diff options
context:
space:
mode:
Diffstat (limited to 'dev-python/twisted')
-rw-r--r--dev-python/twisted/Manifest9
-rw-r--r--dev-python/twisted/files/twisted-19.10.0-py38-cgi.patch41
-rw-r--r--dev-python/twisted/files/twisted-19.10.0-py38.patch110
-rw-r--r--dev-python/twisted/files/twisted-19.10.0-py39-b64.patch165
-rw-r--r--dev-python/twisted/files/twisted-20.3.0-py39-b64.patch158
-rw-r--r--dev-python/twisted/files/twisted-20.3.0-py39-combined.patch115
-rw-r--r--dev-python/twisted/twisted-19.10.0.ebuild15
-rw-r--r--dev-python/twisted/twisted-20.3.0.ebuild4
8 files changed, 610 insertions, 7 deletions
diff --git a/dev-python/twisted/Manifest b/dev-python/twisted/Manifest
index 4483ce309f18..b970e8d38e76 100644
--- a/dev-python/twisted/Manifest
+++ b/dev-python/twisted/Manifest
@@ -7,8 +7,13 @@ AUX twisted-16.6.0-test-fixes.patch 10591 BLAKE2B 27729db1ce4b84ea66acfa12bfdf22
AUX twisted-17.9.0-Fix-test-on-Python-363.patch 3490 BLAKE2B 421318533759dad2d4ad3f054fbfab7900362aa3b3ca0adc75fb42431272fcaa40fe85ab2a3417232d97d3389b380ae658ee5b475e087f3a6097e28dd2094111 SHA512 0ba6b68267418bee3b2cfb15937dab4d6d3291725dd7acc41f37e0c8d39218acc4e23cb704c292f62eea57a128a1fcee6899826601b6763f37800c4b83ad18a8
AUX twisted-17.9.0-python-27-utf-8-fix.patch 1630 BLAKE2B c70f3223b66a9372e07df7a767937d77a07f91cafecb4a5d84452f57458516e3ef17e4d5862d6b9f003e0edce3391e282f5bfcaf57ff2029db3c499fc6e97262 SHA512 635c498ab0e612b7d7ab262c333f18408e22dbe95d86389e87da36f0c41cee90f25b4c1df626cb755932c970a9f12dc25ca67e3790bd9c15c8a4d8ee6f547956
AUX twisted-18.4.0-Disable-writing-of-plugin-cache.patch 853 BLAKE2B f2f4f3906266199856056d4eae062aafaa8d5b574858bd494d6a51512ad3f27ee0d813de8a760fbd21bdf479fde0bb1c3e724e13bddceb0d3af83bb8ecb31aa6 SHA512 e27a61855523a64c27e7adfe8ec917fae60149b1bfe0fc555694dc4321669665116046baa8f293d75b4bf68ec19743850062132aa05fed5feab4f582cc75219c
+AUX twisted-19.10.0-py38-cgi.patch 1356 BLAKE2B d172448bd2807dc57ac2a905427f0a91fa93dd17a1e58ab64dc17fc02fe05a81cee4c08aa667c799720cde33877e4b72f8db8df3587d8d8d711988bb2e388128 SHA512 65629acfc2f6dd6686db715024209e9ff12b97d5190c4377e6d88222c85c1d2a1f3502a93801525ee1a0fc0357f2b28ba87db888ea64bccfbfdc74fdfb667f42
+AUX twisted-19.10.0-py38.patch 3997 BLAKE2B 26df585019d5e2aca4257c9a7840a973ee9e1f3dfce65c76b021b8d6ea07ed8c6abca237c11ce75b49994ea7ed95de587a433a6a6f3577cd6f2ddf243d40defd SHA512 bc6eb1b1bbb704fe30c4ef071f8d8e95faaad3089013d11765f30f4b6bdbb108b913b043c071d00c18b53655841cb1810286331c5318d4659ad7c90d90b9fb4e
+AUX twisted-19.10.0-py39-b64.patch 7022 BLAKE2B f59573231a70318aac1f383602725949f033e017c036ab204815816ef168ad122253e903ff577c1a055c12023d06dc49ebfcdecf693d9890476785653860a628 SHA512 5904bcf5eadcd53d038870d6868fec1a81d6327c31b7b2360987a69e6f4046e92e11b52260c53a2361687161a36a5b6f53b24906d404ebe25f86e5bdc11fc6dc
AUX twisted-20.3.0-py38-cgi.patch 8601 BLAKE2B 6eb76eaa1cfe10ba473a334bfd5e5a4c760739550c4aeba5cf68cbf380ca7f24725e102cf0f75b7a384faf639e03d9e80c11e0cc56339319329207a6342a8d55 SHA512 9877f4e3c0ad6d438cb046a04e60affbcbe7b263d06128ec6ea4d726194b044bf9f6c68891373624b435fb434fc878220834d038180d3d203defe31dab44710c
AUX twisted-20.3.0-py38-hmac.patch 3484 BLAKE2B b89587da906517a621ba880eb6eb71cc2f397a7bcf7bcf065f79897626f821d965b2daa0d105af7e48c8c30fb79fb836c02db17058b5ac046ae92f9578899a62 SHA512 a6ed24994bf76a7e602144eed706c61cce531408db050dc2a497fb4131b5594f4d29ebd34c0d780b283460d130dfc88b19ad9cbe5436c0290b9b13eb35c9342b
+AUX twisted-20.3.0-py39-b64.patch 6747 BLAKE2B 1bb6960e5049f43b08e2ba7a56a16616e82f3b18290645b2f14bd15a199d3e1b2767e030a8295fc2d3f4a8a3d1a6e4a5d5d7d55a089da643c593b2a3df174119 SHA512 6f58dcecf07925d15a1373726e03da4083a0266ee6629089b30b0c8ab62bd007579942430989df2d550578067e2c2c542062dd20a38851794f6ef86e85aefb95
+AUX twisted-20.3.0-py39-combined.patch 3752 BLAKE2B 687698bccf6af3213812ae29e7e234c36941f0f7ecfdcfa8c14a6a7b5a433b9ff2a40c2ad870e46b3437210202cf0dc58e17c8d29ebf506c499780355cf60bdb SHA512 81f0b597a7b2609bae5f405388bccf759dd6b0295cf05e6ef2aee76d0f3ab4367a474704aab2753d101be2580d097f30d94acc529035bdb3c3ec43dd035fb733
AUX utf8_overrides.patch 2288 BLAKE2B 450f921f6a07cd56d9311c15c9f2bf342ec82c807325ebb5b5c2fd61572d489ac7f1c8978892530016a343b7284c580def705127c57ce947a2698835e447b8ce SHA512 b495268282e0233c570655b2b3d42ecc90116b22c36cdec4ebf581ce1019abedb7ee301d860ec161b4b5e691d1b747ad45257966b5f510de8dcce8271021e7e8
DIST Twisted-16.6.0.tar.bz2 2979747 BLAKE2B 898e0a0fa3ae8547a801b09118423ec8ad80727dd6d034e3f8a151f084eff5a3fc560f2eb9e76c452a14ec90b36d93e14d3bbb388010c3c5c01fd1c4d5ca16bb SHA512 0b8de0ec7f64457f76c396fced64b366b8e63c6e000a5edc6c6388cd917fb2f95711918cd8edda39e0aa77e2cd32b5d775d23630a5ad10fc013c18f8316300cf
DIST Twisted-18.4.0.tar.bz2 3037019 BLAKE2B 6fc32f7591493ccc4fe03233307b566899b82cd035ba3329b3faaf950339a6653de697ba3873b37b22f9d7f8a66109694b80496917bf61e79c56eeb7e351ac87 SHA512 3733a6df0196ea580187da3576f5fd08f287437528a4e19813056d019cca213c61b62d879d80a12eef38661d3505ba33aac9a4fc956b19afa6da7d37a6465c83
@@ -17,6 +22,6 @@ DIST Twisted-20.3.0.tar.bz2 3127793 BLAKE2B 2e85fc3ec26d89e563c9e79a5d2adea81ff1
DIST twisted-regen-cache.gz 911 BLAKE2B ffd3fcda6c67ffe6fd3ef581c8d507548396b66ed0708e9a5c790095e579c0d5f0f71596acf05712989da2ddef2b8d437eca973bc4d80ef8a9fa852915f38305 SHA512 95a9b931c73017d16d1b5e6b41345dddffe62b6af1a8e93b5e40d06d3d15be17b0dd0181c767ffeeb791534d463764ef9e066fa6c2ee2ac4b53c86d1da8fce03
EBUILD twisted-16.6.0-r3.ebuild 5783 BLAKE2B e6433d34015f3140e93ac698aaaaae9fa822de410debaa5bce42ffc5697e9c11ed0c3180ce8212703746addda39d9b0d4c30dbbef348fb821a65cc6e24d8701d SHA512 181151b8b2667f688fa08ce7aa97e2fc242c8dd168cc5498d17f6224ce18933406ddcf40a8c813a0631f4cd58e498c370d94371043c41d4b18aa44876677b979
EBUILD twisted-18.4.0.ebuild 6270 BLAKE2B edbeb59373d55d728b255223dd7ca09043547c80513be779719704983508dd2be866e4fee90bb023f8817f95659291c262b4d037ba6609164a61d13dd660e5e4 SHA512 ae8aede1151acaa3f94553bdcefc25970e9026f4aef8a81c6a6f8f0a0e7d9c91283ff6eaf1aeb2ed8140021279ed3a985967fd6357b8ad239289604a9cc0a2a5
-EBUILD twisted-19.10.0.ebuild 5626 BLAKE2B ce1efdadb26446207cc15298265331c14826fa3fde3deff9d02b6792d0fa69538bb6aa7a2a0886a0307891dd249fccc7164011d4793978a32cdcaa6aada8d433 SHA512 02c9caeaffa35b155cc993c5bbe3cda32a08d41bd844275892439b55e8824db538e68b6f7343ecddeb8bbd403ca8c1a0b5d7f3af0344a3479e6ff8e08a95fbd1
-EBUILD twisted-20.3.0.ebuild 5488 BLAKE2B 99921ace5a474e645b7f81f6660b8a2498071d88f4434c89da82c8763b1090091dc1db1e6835a3b5b2ad76adfd74647b0bf24be8fe816b683377e125cc0669be SHA512 b5c4f4e73080c4065b2179cacda64d9e5cc51ae377655ddecc9c1b1d928afb97845d70b38716fac19c4138dc45fb7b7a7cc12a96046e534a9f086c066a38afd4
+EBUILD twisted-19.10.0.ebuild 5878 BLAKE2B 23231a9145a514d363600656ebc0ca2136b8be060559131fbdd9adb5235d1bd734383aca7a37e7c0befd005fce67723e55a288117a0e2273862055067f13af5f SHA512 14604830d9de35e8ea66334af5b0c9fc42a562b03d4b20425c579c654eff18047860e9cb100243c9884599fc5294b6018b3c77f54175bcb8c549aedfb0477a95
+EBUILD twisted-20.3.0.ebuild 5587 BLAKE2B a87b12179d3a460ca7185c1ba71d51f49d59934b355e3d62628c5f3eda4192572892c3a640222a22321b0a494d723aca011564609a97e28ddd553e380c5795d6 SHA512 2cfa6cc45ec6a8e1cf182c21a279d5389df6a267fa2343c7342fb305b5bb143915cf82f61dbb234cf12bbf6ca1f92935abd5c0fc891932f3d97bb08edbdc0f13
MISC metadata.xml 1351 BLAKE2B b3a4ccdc922dd4aa902b24b2545f3cc5517b2842c92f1195e8eaa2a8b62558c1ea86059cc23b9ad6a8e6093216a11a01f46360b5ba259e5eadcb351ad3bc0094 SHA512 403d692122913d079c5a93cb5b226f33316776360663a171cd757584d219d0789b24809c9e65840aaeb63eae4cb7cc79258757837abb1e3dd92536369fff6604
diff --git a/dev-python/twisted/files/twisted-19.10.0-py38-cgi.patch b/dev-python/twisted/files/twisted-19.10.0-py38-cgi.patch
new file mode 100644
index 000000000000..5fc4768e5d23
--- /dev/null
+++ b/dev-python/twisted/files/twisted-19.10.0-py38-cgi.patch
@@ -0,0 +1,41 @@
+diff --git a/src/twisted/web/test/test_http.py b/src/twisted/web/test/test_http.py
+index 6001d1e40..1cf9172ef 100644
+--- a/src/twisted/web/test/test_http.py
++++ b/src/twisted/web/test/test_http.py
+@@ -9,15 +9,15 @@ from __future__ import absolute_import, division
+
+ import base64
+ import calendar
+-import cgi
+ import random
+
+ import hamcrest
+
+ try:
+ from urlparse import urlparse, urlunsplit, clear_cache
++ from cgi import parse_qs
+ except ImportError:
+- from urllib.parse import urlparse, urlunsplit, clear_cache
++ from urllib.parse import urlparse, urlunsplit, clear_cache, parse_qs
+
+ from io import BytesIO
+ from itertools import cycle
+@@ -2156,15 +2156,15 @@ Hello,
+ class QueryArgumentsTests(unittest.TestCase):
+ def testParseqs(self):
+ self.assertEqual(
+- cgi.parse_qs(b"a=b&d=c;+=f"),
++ parse_qs(b"a=b&d=c;+=f"),
+ http.parse_qs(b"a=b&d=c;+=f"))
+ self.assertRaises(
+ ValueError, http.parse_qs, b"blah", strict_parsing=True)
+ self.assertEqual(
+- cgi.parse_qs(b"a=&b=c", keep_blank_values=1),
++ parse_qs(b"a=&b=c", keep_blank_values=1),
+ http.parse_qs(b"a=&b=c", keep_blank_values=1))
+ self.assertEqual(
+- cgi.parse_qs(b"a=&b=c"),
++ parse_qs(b"a=&b=c"),
+ http.parse_qs(b"a=&b=c"))
+
+
diff --git a/dev-python/twisted/files/twisted-19.10.0-py38.patch b/dev-python/twisted/files/twisted-19.10.0-py38.patch
new file mode 100644
index 000000000000..e787167d45b3
--- /dev/null
+++ b/dev-python/twisted/files/twisted-19.10.0-py38.patch
@@ -0,0 +1,110 @@
+From d33b90880b8eb024daa73bc3fd39aca0bc791ff1 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Lucas=20Treffenst=C3=A4dt?= <lucas@treffenstaedt.de>
+Date: Mon, 13 Jan 2020 13:54:08 +0100
+Subject: [PATCH 1/2] CramMD5ClientAuthenticator now specifies the digestmod
+ argument to hmac.HMAC constructor explicitly.
+
+---
+ src/twisted/mail/_cred.py | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/src/twisted/mail/_cred.py b/src/twisted/mail/_cred.py
+index 9d3646948..43c406f90 100644
+--- a/src/twisted/mail/_cred.py
++++ b/src/twisted/mail/_cred.py
+@@ -8,6 +8,7 @@ Credential managers for L{twisted.mail}.
+ from __future__ import absolute_import, division
+
+ import hmac
++import hashlib
+
+ from zope.interface import implementer
+
+@@ -28,7 +29,7 @@ class CramMD5ClientAuthenticator:
+
+
+ def challengeResponse(self, secret, chal):
+- response = hmac.HMAC(secret, chal).hexdigest().encode('ascii')
++ response = hmac.HMAC(secret, chal, digestmod = hashlib.md5).hexdigest().encode('ascii')
+ return self.user + b' ' + response
+
+
+--
+2.26.2
+
+From 694bc67f3cf7d36a6f512f0b76882e85d0966dd2 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Poisson?= <goffi@goffi.org>
+Date: Sun, 17 Nov 2019 19:48:53 +0100
+Subject: [PATCH 2/2] Fix parsing of namespaced attributes with Python 3.8 in
+ twisted.words.xish.domish.ExpatElementStream
+
+---
+ src/twisted/words/newsfragments/9730.bugfix | 1 +
+ src/twisted/words/test/test_domish.py | 17 +++++++++++++++++
+ src/twisted/words/xish/domish.py | 11 +++++++++--
+ 3 files changed, 27 insertions(+), 2 deletions(-)
+ create mode 100644 src/twisted/words/newsfragments/9730.bugfix
+
+diff --git a/src/twisted/words/newsfragments/9730.bugfix b/src/twisted/words/newsfragments/9730.bugfix
+new file mode 100644
+index 000000000..5c91305c8
+--- /dev/null
++++ b/src/twisted/words/newsfragments/9730.bugfix
+@@ -0,0 +1 @@
++Fixed parsing of streams with Python 3.8 when there are spaces in namespaces or namespaced attributes in twisted.words.xish.domish.ExpatElementStream
+diff --git a/src/twisted/words/test/test_domish.py b/src/twisted/words/test/test_domish.py
+index a8f8fa76b..cd16e3a4d 100644
+--- a/src/twisted/words/test/test_domish.py
++++ b/src/twisted/words/test/test_domish.py
+@@ -350,6 +350,23 @@ class DomishStreamTestsMixin:
+ self.elements[0].attributes, {(" bar baz ", "baz"): "quux"})
+
+
++ def test_attributesWithNamespaces(self):
++ """
++ Attributes with namespace are parsed without Exception.
++ (https://twistedmatrix.com/trac/ticket/9730 regression test)
++ """
++
++ xml = b"""<root xmlns:test='http://example.org' xml:lang='en'>
++ <test:test>test</test:test>
++ </root>"""
++
++ # with Python 3.8 and without #9730 fix, the following error would
++ # happen at next line:
++ # ``RuntimeError: dictionary keys changed during iteration``
++ self.stream.parse(xml)
++ self.assertEqual(self.elements[0].uri, "http://example.org")
++
++
+ def testChildPrefix(self):
+ xml = b"<root xmlns='testns' xmlns:foo='testns2'><foo:child/></root>"
+
+diff --git a/src/twisted/words/xish/domish.py b/src/twisted/words/xish/domish.py
+index 2063c410a..fc49285f5 100644
+--- a/src/twisted/words/xish/domish.py
++++ b/src/twisted/words/xish/domish.py
+@@ -807,11 +807,18 @@ class ExpatElementStream:
+ qname = ('', name)
+
+ # Process attributes
++ newAttrs = {}
++ toDelete = []
+ for k, v in attrs.items():
+ if " " in k:
+ aqname = k.rsplit(" ", 1)
+- attrs[(aqname[0], aqname[1])] = v
+- del attrs[k]
++ newAttrs[(aqname[0], aqname[1])] = v
++ toDelete.append(k)
++
++ attrs.update(newAttrs)
++
++ for k in toDelete:
++ del attrs[k]
+
+ # Construct the new element
+ e = Element(qname, self.defaultNsStack[-1], attrs, self.localPrefixes)
+--
+2.26.2
+
diff --git a/dev-python/twisted/files/twisted-19.10.0-py39-b64.patch b/dev-python/twisted/files/twisted-19.10.0-py39-b64.patch
new file mode 100644
index 000000000000..f67d6240558a
--- /dev/null
+++ b/dev-python/twisted/files/twisted-19.10.0-py39-b64.patch
@@ -0,0 +1,165 @@
+From f56133a2e0d7ddf9ee6e43bf9e1d62e970cb0b3a Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
+Date: Wed, 27 May 2020 13:23:37 +0200
+Subject: [PATCH] Replace base64.*string() functions to fix py3.9 support
+
+Replace base64.decodestring() and .encodestring() functions as they
+were deprecated since Python 3.1 in favor of (equivalent) .decodebytes()
+and .encodebytes(), and were eventually removed in Python 3.9.
+
+While at it, replace most of their uses with base64.b64encode()
+and .b64decode() that are preferable to the former wrt ticket #6446,
+and they do not introduce line breaks that the twisted code usually
+discarded.
+
+Use .decodebytes() and .encodebytes() in DirDBM as it seems to rely
+on the exact presence of newlines, and changing that would break
+backwards compatibility.
+
+Fixes: ticket:6446
+Fixes: ticket:9831
+---
+ src/twisted/conch/scripts/tkconch.py | 2 +-
+ src/twisted/conch/test/test_keys.py | 2 +-
+ src/twisted/mail/pop3.py | 4 ++--
+ src/twisted/mail/test/test_pop3.py | 4 ++--
+ src/twisted/persisted/dirdbm.py | 10 ++++++++--
+ src/twisted/web/http.py | 2 +-
+ src/twisted/web/test/test_http.py | 6 +++---
+ 14 files changed, 18 insertions(+), 12 deletions(-)
+
+diff --git a/src/twisted/conch/scripts/tkconch.py b/src/twisted/conch/scripts/tkconch.py
+index 9c48e8a7f..5e007ebdc 100644
+--- a/src/twisted/conch/scripts/tkconch.py
++++ b/src/twisted/conch/scripts/tkconch.py
+@@ -409,7 +409,7 @@ class SSHClientTransport(transport.SSHClientTransport):
+ "known hosts.\r\n" %
+ (khHost, {b'ssh-dss':'DSA', b'ssh-rsa':'RSA'}[keyType]))
+ with open(os.path.expanduser('~/.ssh/known_hosts'), 'a') as known_hosts:
+- encodedKey = base64.encodestring(pubKey).replace(b'\n', b'')
++ encodedKey = base64.b64encode(pubKey)
+ known_hosts.write('\n%s %s %s' % (khHost, keyType, encodedKey))
+ except:
+ log.deferr()
+diff --git a/src/twisted/conch/test/test_keys.py b/src/twisted/conch/test/test_keys.py
+index 41e49f415..795e7b8d7 100644
+--- a/src/twisted/conch/test/test_keys.py
++++ b/src/twisted/conch/test/test_keys.py
+@@ -352,7 +352,7 @@ SUrCyZXsNh6VXwjs3gKQ
+
+ self.assertRaises(
+ keys.BadKeyError,
+- keys.Key.fromString, data=b'{' + base64.encodestring(sexp) + b'}',
++ keys.Key.fromString, data=b'{' + base64.b64encode(sexp) + b'}',
+ )
+
+
+diff --git a/src/twisted/mail/pop3.py b/src/twisted/mail/pop3.py
+index ffe9714c9..057389e3a 100644
+--- a/src/twisted/mail/pop3.py
++++ b/src/twisted/mail/pop3.py
+@@ -728,7 +728,7 @@ class POP3(basic.LineOnlyReceiver, policies.TimeoutMixin):
+ self._auth = auth()
+ chal = self._auth.getChallenge()
+
+- self.sendLine(b'+ ' + base64.encodestring(chal).rstrip(b'\n'))
++ self.sendLine(b'+ ' + base64.b64encode(chal))
+ self.state = 'AUTH'
+
+
+@@ -747,7 +747,7 @@ class POP3(basic.LineOnlyReceiver, policies.TimeoutMixin):
+ """
+ self.state = "COMMAND"
+ try:
+- parts = base64.decodestring(line).split(None, 1)
++ parts = base64.b64decode(line).split(None, 1)
+ except binascii.Error:
+ self.failResponse(b"Invalid BASE64 encoding")
+ else:
+diff --git a/src/twisted/mail/test/test_pop3.py b/src/twisted/mail/test/test_pop3.py
+index ea513487c..36780d9c9 100644
+--- a/src/twisted/mail/test/test_pop3.py
++++ b/src/twisted/mail/test/test_pop3.py
+@@ -1097,12 +1097,12 @@ class SASLTests(unittest.TestCase):
+
+ p.lineReceived(b"AUTH CRAM-MD5")
+ chal = s.getvalue().splitlines()[-1][2:]
+- chal = base64.decodestring(chal)
++ chal = base64.b64decode(chal)
+ response = hmac.HMAC(b'testpassword', chal,
+ digestmod=md5).hexdigest().encode("ascii")
+
+ p.lineReceived(
+- base64.encodestring(b'testuser ' + response).rstrip(b'\n'))
++ base64.b64encode(b'testuser ' + response))
+ self.assertTrue(p.mbox)
+ self.assertTrue(s.getvalue().splitlines()[-1].find(b"+OK") >= 0)
+ p.connectionLost(failure.Failure(Exception("Test harness disconnect")))
+diff --git a/src/twisted/persisted/dirdbm.py b/src/twisted/persisted/dirdbm.py
+index f97c526d0..d9f29cce2 100644
+--- a/src/twisted/persisted/dirdbm.py
++++ b/src/twisted/persisted/dirdbm.py
+@@ -81,14 +81,20 @@ class DirDBM:
+ Encode a key so it can be used as a filename.
+ """
+ # NOTE: '_' is NOT in the base64 alphabet!
+- return base64.encodestring(k).replace(b'\n', b'_').replace(b"/", b"-")
++ try:
++ return base64.encodebytes(k).replace(b'\n', b'_').replace(b"/", b"-")
++ except AttributeError:
++ return base64.encodestring(k).replace(b'\n', b'_').replace(b"/", b"-")
+
+
+ def _decode(self, k):
+ """
+ Decode a filename to get the key.
+ """
+- return base64.decodestring(k.replace(b'_', b'\n').replace(b"-", b"/"))
++ try:
++ return base64.decodebytes(k.replace(b'_', b'\n').replace(b"-", b"/"))
++ except AttributeError:
++ return base64.decodestring(k.replace(b'_', b'\n').replace(b"-", b"/"))
+
+
+ def _readFile(self, path):
+diff --git a/src/twisted/web/http.py b/src/twisted/web/http.py
+index fe88d3373..602a58f31 100644
+--- a/src/twisted/web/http.py
++++ b/src/twisted/web/http.py
+@@ -1540,7 +1540,7 @@ class Request:
+ bas, upw = authh.split()
+ if bas.lower() != b"basic":
+ raise ValueError()
+- upw = base64.decodestring(upw)
++ upw = base64.b64decode(upw)
+ self.user, self.password = upw.split(b':', 1)
+ except (binascii.Error, ValueError):
+ self.user = self.password = ""
+diff --git a/src/twisted/web/test/test_http.py b/src/twisted/web/test/test_http.py
+index 6001d1e40..70065e232 100644
+--- a/src/twisted/web/test/test_http.py
++++ b/src/twisted/web/test/test_http.py
+@@ -1513,7 +1513,7 @@ class ParsingTests(unittest.TestCase):
+ requests.append(self)
+
+ for u, p in [(b"foo", b"bar"), (b"hello", b"there:z")]:
+- s = base64.encodestring(b":".join((u, p))).strip()
++ s = base64.b64encode(b":".join((u, p)))
+ f = b"GET / HTTP/1.0\nAuthorization: Basic " + s + b"\n\n"
+ self.runRequest(f, Request, 0)
+ req = requests.pop()
+@@ -2139,9 +2139,9 @@ Hello,
+
+ u = b"foo"
+ p = b"bar"
+- s = base64.encodestring(b":".join((u, p))).strip()
++ s = base64.b64encode(b":".join((u, p)))
+ f = b"GET / HTTP/1.0\nAuthorization: Basic " + s + b"\n\n"
+- self.patch(base64, 'decodestring', lambda x: [])
++ self.patch(base64, 'b64decode', lambda x: [])
+ self.runRequest(f, Request, 0)
+ req = requests.pop()
+ self.assertEqual(('', ''), req.credentials)
+--
+2.26.2
+
diff --git a/dev-python/twisted/files/twisted-20.3.0-py39-b64.patch b/dev-python/twisted/files/twisted-20.3.0-py39-b64.patch
new file mode 100644
index 000000000000..f475614df408
--- /dev/null
+++ b/dev-python/twisted/files/twisted-20.3.0-py39-b64.patch
@@ -0,0 +1,158 @@
+From f44c2ff111a8961d295409186cc07aaf414c76bc Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
+Date: Wed, 27 May 2020 13:23:37 +0200
+Subject: [PATCH 1/4] Replace base64.*string() functions to fix py3.9 support
+
+Replace base64.decodestring() and .encodestring() functions as they
+were deprecated since Python 3.1 in favor of (equivalent) .decodebytes()
+and .encodebytes(), and were eventually removed in Python 3.9.
+
+While at it, replace most of their uses with base64.b64encode()
+and .b64decode() that are preferable to the former wrt ticket #6446,
+and they do not introduce line breaks that the twisted code usually
+discarded.
+
+Use .decodebytes() and .encodebytes() in DirDBM as it seems to rely
+on the exact presence of newlines, and changing that would break
+backwards compatibility.
+
+Fixes: ticket:6446
+Fixes: ticket:9831
+---
+ src/twisted/conch/scripts/tkconch.py | 2 +-
+ src/twisted/conch/test/test_keys.py | 2 +-
+ src/twisted/mail/pop3.py | 4 ++--
+ src/twisted/mail/test/test_pop3.py | 4 ++--
+ src/twisted/persisted/dirdbm.py | 4 ++--
+ src/twisted/web/http.py | 2 +-
+ src/twisted/web/test/test_http.py | 6 +++---
+ 14 files changed, 12 insertions(+), 12 deletions(-)
+
+diff --git a/src/twisted/conch/scripts/tkconch.py b/src/twisted/conch/scripts/tkconch.py
+index a662cabc8..744734343 100644
+--- a/src/twisted/conch/scripts/tkconch.py
++++ b/src/twisted/conch/scripts/tkconch.py
+@@ -412,7 +412,7 @@ class SSHClientTransport(transport.SSHClientTransport):
+ "known hosts.\r\n" %
+ (khHost, {b'ssh-dss':'DSA', b'ssh-rsa':'RSA'}[keyType]))
+ with open(os.path.expanduser('~/.ssh/known_hosts'), 'a') as known_hosts:
+- encodedKey = base64.encodestring(pubKey).replace(b'\n', b'')
++ encodedKey = base64.b64encode(pubKey)
+ known_hosts.write('\n%s %s %s' % (khHost, keyType, encodedKey))
+ except:
+ log.deferr()
+diff --git a/src/twisted/conch/test/test_keys.py b/src/twisted/conch/test/test_keys.py
+index 650a19bfb..f76cbd1b4 100644
+--- a/src/twisted/conch/test/test_keys.py
++++ b/src/twisted/conch/test/test_keys.py
+@@ -404,7 +404,7 @@ SUrCyZXsNh6VXwjs3gKQ
+
+ self.assertRaises(
+ keys.BadKeyError,
+- keys.Key.fromString, data=b'{' + base64.encodestring(sexp) + b'}',
++ keys.Key.fromString, data=b'{' + base64.b64encode(sexp) + b'}',
+ )
+
+
+diff --git a/src/twisted/mail/pop3.py b/src/twisted/mail/pop3.py
+index ffe9714c9..057389e3a 100644
+--- a/src/twisted/mail/pop3.py
++++ b/src/twisted/mail/pop3.py
+@@ -728,7 +728,7 @@ class POP3(basic.LineOnlyReceiver, policies.TimeoutMixin):
+ self._auth = auth()
+ chal = self._auth.getChallenge()
+
+- self.sendLine(b'+ ' + base64.encodestring(chal).rstrip(b'\n'))
++ self.sendLine(b'+ ' + base64.b64encode(chal))
+ self.state = 'AUTH'
+
+
+@@ -747,7 +747,7 @@ class POP3(basic.LineOnlyReceiver, policies.TimeoutMixin):
+ """
+ self.state = "COMMAND"
+ try:
+- parts = base64.decodestring(line).split(None, 1)
++ parts = base64.b64decode(line).split(None, 1)
+ except binascii.Error:
+ self.failResponse(b"Invalid BASE64 encoding")
+ else:
+diff --git a/src/twisted/mail/test/test_pop3.py b/src/twisted/mail/test/test_pop3.py
+index f7fbfaf1e..af335ab2d 100644
+--- a/src/twisted/mail/test/test_pop3.py
++++ b/src/twisted/mail/test/test_pop3.py
+@@ -1096,12 +1096,12 @@ class SASLTests(unittest.TestCase):
+
+ p.lineReceived(b"AUTH CRAM-MD5")
+ chal = s.getvalue().splitlines()[-1][2:]
+- chal = base64.decodestring(chal)
++ chal = base64.b64decode(chal)
+ response = hmac.HMAC(b'testpassword', chal,
+ digestmod=md5).hexdigest().encode("ascii")
+
+ p.lineReceived(
+- base64.encodestring(b'testuser ' + response).rstrip(b'\n'))
++ base64.b64encode(b'testuser ' + response))
+ self.assertTrue(p.mbox)
+ self.assertTrue(s.getvalue().splitlines()[-1].find(b"+OK") >= 0)
+ p.connectionLost(failure.Failure(Exception("Test harness disconnect")))
+diff --git a/src/twisted/persisted/dirdbm.py b/src/twisted/persisted/dirdbm.py
+index 3ba7a59d4..7659ff765 100644
+--- a/src/twisted/persisted/dirdbm.py
++++ b/src/twisted/persisted/dirdbm.py
+@@ -77,14 +77,14 @@ class DirDBM:
+ Encode a key so it can be used as a filename.
+ """
+ # NOTE: '_' is NOT in the base64 alphabet!
+- return base64.encodestring(k).replace(b'\n', b'_').replace(b"/", b"-")
++ return base64.encodebytes(k).replace(b'\n', b'_').replace(b"/", b"-")
+
+
+ def _decode(self, k):
+ """
+ Decode a filename to get the key.
+ """
+- return base64.decodestring(k.replace(b'_', b'\n').replace(b"-", b"/"))
++ return base64.decodebytes(k.replace(b'_', b'\n').replace(b"-", b"/"))
+
+
+ def _readFile(self, path):
+diff --git a/src/twisted/web/http.py b/src/twisted/web/http.py
+index 0e115741e..e9a080d21 100644
+--- a/src/twisted/web/http.py
++++ b/src/twisted/web/http.py
+@@ -1544,7 +1544,7 @@ class Request:
+ bas, upw = authh.split()
+ if bas.lower() != b"basic":
+ raise ValueError()
+- upw = base64.decodestring(upw)
++ upw = base64.b64decode(upw)
+ self.user, self.password = upw.split(b':', 1)
+ except (binascii.Error, ValueError):
+ self.user = self.password = b''
+diff --git a/src/twisted/web/test/test_http.py b/src/twisted/web/test/test_http.py
+index 112e56f46..02a4674a7 100644
+--- a/src/twisted/web/test/test_http.py
++++ b/src/twisted/web/test/test_http.py
+@@ -1604,7 +1604,7 @@ class ParsingTests(unittest.TestCase):
+ requests.append(self)
+
+ for u, p in [(b"foo", b"bar"), (b"hello", b"there:z")]:
+- s = base64.encodestring(b":".join((u, p))).strip()
++ s = base64.b64encode(b":".join((u, p)))
+ f = b"GET / HTTP/1.0\nAuthorization: Basic " + s + b"\n\n"
+ self.runRequest(f, Request, 0)
+ req = requests.pop()
+@@ -2209,9 +2209,9 @@ Hello,
+
+ u = b"foo"
+ p = b"bar"
+- s = base64.encodestring(b":".join((u, p))).strip()
++ s = base64.b64encode(b":".join((u, p)))
+ f = b"GET / HTTP/1.0\nAuthorization: Basic " + s + b"\n\n"
+- self.patch(base64, 'decodestring', lambda x: [])
++ self.patch(base64, 'b64decode', lambda x: [])
+ self.runRequest(f, Request, 0)
+ req = requests.pop()
+ self.assertEqual((b'', b''), req.credentials)
+--
+2.26.2
diff --git a/dev-python/twisted/files/twisted-20.3.0-py39-combined.patch b/dev-python/twisted/files/twisted-20.3.0-py39-combined.patch
new file mode 100644
index 000000000000..0ed1f7b8d9c6
--- /dev/null
+++ b/dev-python/twisted/files/twisted-20.3.0-py39-combined.patch
@@ -0,0 +1,115 @@
+From 2d30860a8b71e90513ead9958f5dd312802b0d36 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
+Date: Wed, 27 May 2020 14:40:53 +0200
+Subject: [PATCH 2/4] Fix imap4-utf-7 codec lookup function for Python 3.9
+
+Python 3.9 normalizes the codec name into 'imap4_utf_7' rather than
+'imap4-utf-7', and therefore the lookup function needs to account
+for the former name. Transform the latter locally to preserve support
+for all Python versions.
+
+Fixes: ticket: 9832
+---
+ src/twisted/mail/imap4.py | 2 +-
+ 2 files changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/twisted/mail/imap4.py b/src/twisted/mail/imap4.py
+index 736ef111d..3f32982ca 100644
+--- a/src/twisted/mail/imap4.py
++++ b/src/twisted/mail/imap4.py
+@@ -6369,7 +6369,7 @@ _codecInfo = codecs.CodecInfo(encoder, decoder, StreamReader, StreamWriter)
+
+
+ def imap4_utf_7(name):
+- if name == 'imap4-utf-7':
++ if name.replace('-', '_') == 'imap4_utf_7':
+ return _codecInfo
+
+ codecs.register(imap4_utf_7)
+--
+2.26.2
+
+From daf928bf0f0371816dddbd4929948c4213d0cdcb Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
+Date: Wed, 27 May 2020 15:12:54 +0200
+Subject: [PATCH 3/4] Fix verifyCryptedPassword() for crypt.crypt() throwing in
+ py3.9
+
+In Python 3.9, the crypt.crypt() function may throw an exception
+if the underlying crypt() function fails. Update
+verifyCryptedPassword() to account for that, and preserve the existing
+behavior of returning False in that case.
+
+Fixes: ticket:9833
+---
+ src/twisted/conch/checkers.py | 5 ++++-
+ src/twisted/plugins/cred_unix.py | 5 ++++-
+ 4 files changed, 8 insertions(+), 2 deletions(-)
+
+diff --git a/src/twisted/conch/checkers.py b/src/twisted/conch/checkers.py
+index 917567a39..e4e327b16 100644
+--- a/src/twisted/conch/checkers.py
++++ b/src/twisted/conch/checkers.py
+@@ -53,7 +53,10 @@ def verifyCryptedPassword(crypted, pw):
+
+ @rtype: L{bool}
+ """
+- return crypt.crypt(pw, crypted) == crypted
++ try:
++ return crypt.crypt(pw, crypted) == crypted
++ except OSError:
++ return False
+
+
+
+diff --git a/src/twisted/plugins/cred_unix.py b/src/twisted/plugins/cred_unix.py
+index 211b4ccbc..a662719b6 100644
+--- a/src/twisted/plugins/cred_unix.py
++++ b/src/twisted/plugins/cred_unix.py
+@@ -43,7 +43,10 @@ def verifyCryptedPassword(crypted, pw):
+ pw = pw.decode('utf-8')
+ if not isinstance(crypted, StringType):
+ crypted = crypted.decode('utf-8')
+- return crypt.crypt(pw, crypted) == crypted
++ try:
++ return crypt.crypt(pw, crypted) == crypted
++ except OSError:
++ return False
+
+
+
+--
+2.26.2
+
+From 4fc435df0d1eba3e5d6416a2b86d39d3404f82fe Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
+Date: Wed, 27 May 2020 15:37:10 +0200
+Subject: [PATCH 4/4] Use xml.etree.ElementTree instead of deprecated
+ cElementTree
+
+The xml.etree.cElementTree is deprecated, and has been removed in Python
+3.9. At the same time, xml.etree.ElementTree has already been using
+cElementTree implicitly since Python 3.3. Update test_flatten to use
+the latter to provide compatibility with newer Python versions.
+
+Fixes: ticket:9834
+---
+ src/twisted/web/test/test_flatten.py | 2 +-
+ 2 files changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/twisted/web/test/test_flatten.py b/src/twisted/web/test/test_flatten.py
+index 677401c55..61d50e20a 100644
+--- a/src/twisted/web/test/test_flatten.py
++++ b/src/twisted/web/test/test_flatten.py
+@@ -9,7 +9,7 @@ L{twisted.web._flatten}.
+ import sys
+ import traceback
+
+-from xml.etree.cElementTree import XML
++from xml.etree.ElementTree import XML
+
+ from collections import OrderedDict
+
+--
+2.26.2
+
diff --git a/dev-python/twisted/twisted-19.10.0.ebuild b/dev-python/twisted/twisted-19.10.0.ebuild
index d092c5697894..720e3b98f647 100644
--- a/dev-python/twisted/twisted-19.10.0.ebuild
+++ b/dev-python/twisted/twisted-19.10.0.ebuild
@@ -3,7 +3,7 @@
EAPI=7
-PYTHON_COMPAT=( python2_7 python3_{6,7,8} )
+PYTHON_COMPAT=( python2_7 python3_{6,7,8,9} )
PYTHON_REQ_USE="threads(+)"
inherit distutils-r1 virtualx
@@ -17,8 +17,9 @@ HOMEPAGE="https://www.twistedmatrix.com/trac/"
SRC_URI="https://twistedmatrix.com/Releases/${TWISTED_PN}"
SRC_URI="${SRC_URI}/${TWISTED_RELEASE}/${TWISTED_P}.tar.bz2
https://dev.gentoo.org/~mgorny/dist/twisted-regen-cache.gz"
+S=${WORKDIR}/${TWISTED_P}
-KEYWORDS="~alpha amd64 arm arm64 ~ia64 ~mips ppc ppc64 s390 sparc x86 ~amd64-linux ~x86-linux"
+KEYWORDS="~alpha amd64 arm arm64 ~hppa ~ia64 ~mips ppc ppc64 s390 sparc x86 ~amd64-linux ~x86-linux"
LICENSE="MIT"
SLOT="0"
@@ -79,9 +80,15 @@ DEPEND="
)
"
-S=${WORKDIR}/${TWISTED_P}
-
python_prepare_all() {
+ local PATCHES=(
+ "${FILESDIR}"/${P}-py38.patch
+ "${FILESDIR}"/twisted-19.10.0-py38-cgi.patch
+ "${FILESDIR}"/twisted-20.3.0-py38-hmac.patch
+ "${FILESDIR}"/twisted-19.10.0-py39-b64.patch
+ "${FILESDIR}"/twisted-20.3.0-py39-combined.patch
+ )
+
# upstream test for making releases; not very useful and requires
# sphinx (including on py2)
rm src/twisted/python/test/test_release.py || die
diff --git a/dev-python/twisted/twisted-20.3.0.ebuild b/dev-python/twisted/twisted-20.3.0.ebuild
index 47624031dc76..3ee3d08b812a 100644
--- a/dev-python/twisted/twisted-20.3.0.ebuild
+++ b/dev-python/twisted/twisted-20.3.0.ebuild
@@ -3,7 +3,7 @@
EAPI=7
-PYTHON_COMPAT=( python3_{6,7,8} )
+PYTHON_COMPAT=( python3_{6,7,8,9} )
PYTHON_REQ_USE="threads(+)"
inherit distutils-r1 virtualx
@@ -84,6 +84,8 @@ python_prepare_all() {
local PATCHES=(
"${FILESDIR}"/twisted-20.3.0-py38-cgi.patch
"${FILESDIR}"/twisted-20.3.0-py38-hmac.patch
+ "${FILESDIR}"/twisted-20.3.0-py39-b64.patch
+ "${FILESDIR}"/twisted-20.3.0-py39-combined.patch
)
# upstream test for making releases; not very useful and requires