mirror of
https://github.com/gentoo-mirror/gentoo.git
synced 2026-09-24 04:59:14 -07:00
dev-python/twisted: Remove old
Signed-off-by: Michał Górny <mgorny@gentoo.org>
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
DIST Twisted-19.10.0.tar.bz2 3118485 BLAKE2B a0d532b67177aa017e463bf823d7842d4f6ff694f78cd7600865718ffe861023a53ea6a922f7de232133edba26f5255074d7ef277ce8f3bdf02d556ccf4abf41 SHA512 de8d7fd0b2081cebeff68b060c8469377011648bc563a94a993d3530fb007ed42c3a54925c9a10c465ee7a3065cc9108ace12d10d358223fab13494becb9ac4b
|
||||
DIST Twisted-20.3.0.tar.bz2 3127793 BLAKE2B 2e85fc3ec26d89e563c9e79a5d2adea81ff1745d18f0f92b8d45ae3729fbddf09998664257880372c7a4caeb5977c5cad7c863596b8c27ad7890275cead9f763 SHA512 1b850e5fc21a3630ead4c2cc3622c16e78bb3be38ab11d021779b7ce3d3c30acc4e19d79c7791a5fce6c5c6e09c2baa349901dffe952de67dd98eec419846365
|
||||
DIST twisted-21.2.0.tar.gz 3882978 BLAKE2B ba37572b0f9eadf2962a2730e4c2c0ed65f582b11b3350034660a2c53c5cd0892b19867d19e0201d4808c09fca621dbe540d153dc6c7d5827d45d2423d19d28b SHA512 fa743dcf22f3c17dfd17f39b7df0cc31fb8ce3e989478ada9a026424ec2de35e6a403ef35acdef5905eed008d42e3c2fee6b7ccdda433e6c250f1feaa83ea8a4
|
||||
DIST twisted-21.7.0.tar.gz 3895345 BLAKE2B 510165ad2933f07005e508df5a8bdf2863a7988c0f18fcc089e948d190c65aab32fc876d3120e311e91d6989f1ea2d8b3b5f5db4a9dfc63c38da56213f718728 SHA512 a946769a6bc6c72af26e7763b9e0675788f134b4d005ea89d935da1b1d5f60d92c84fdb2615e442e7da2b98291ee8a63d5236ec7ba72ef04ad3f847b092feecb
|
||||
DIST twisted-regen-cache.gz 911 BLAKE2B ffd3fcda6c67ffe6fd3ef581c8d507548396b66ed0708e9a5c790095e579c0d5f0f71596acf05712989da2ddef2b8d437eca973bc4d80ef8a9fa852915f38305 SHA512 95a9b931c73017d16d1b5e6b41345dddffe62b6af1a8e93b5e40d06d3d15be17b0dd0181c767ffeeb791534d463764ef9e066fa6c2ee2ac4b53c86d1da8fce03
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
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"))
|
||||
|
||||
|
||||
@@ -1,110 +0,0 @@
|
||||
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
|
||||
|
||||
@@ -1,165 +0,0 @@
|
||||
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
|
||||
|
||||
@@ -1,259 +0,0 @@
|
||||
From 62ab0203c59c1f9788c53dfad4a212774094d05c Mon Sep 17 00:00:00 2001
|
||||
From: Craig Rodrigues <rodrigc@FreeBSD.org>
|
||||
Date: Mon, 13 Apr 2020 01:22:23 -0700
|
||||
Subject: [PATCH 2/2] Merge 9801-rodrigc-cgi: Change import of cgi.parse_qs to
|
||||
urllib.parse.parse_qs
|
||||
|
||||
Author: rodrigc
|
||||
Reviewer: hawkowl
|
||||
Fixes: ticket:9801
|
||||
---
|
||||
src/twisted/web/client.py | 17 ++++-----
|
||||
src/twisted/web/http.py | 49 ++++++++++++-------------
|
||||
src/twisted/web/newsfragments/9801.misc | 0
|
||||
src/twisted/web/test/test_http.py | 41 +++------------------
|
||||
src/twisted/web/test/test_webclient.py | 5 +--
|
||||
5 files changed, 38 insertions(+), 74 deletions(-)
|
||||
create mode 100644 src/twisted/web/newsfragments/9801.misc
|
||||
|
||||
diff --git a/src/twisted/web/client.py b/src/twisted/web/client.py
|
||||
index 7e4642ef3..8209f5a5e 100644
|
||||
--- a/src/twisted/web/client.py
|
||||
+++ b/src/twisted/web/client.py
|
||||
@@ -12,15 +12,8 @@ import os
|
||||
import collections
|
||||
import warnings
|
||||
|
||||
-try:
|
||||
- from urlparse import urlunparse, urljoin, urldefrag
|
||||
-except ImportError:
|
||||
- from urllib.parse import urljoin, urldefrag
|
||||
- from urllib.parse import urlunparse as _urlunparse
|
||||
-
|
||||
- def urlunparse(parts):
|
||||
- result = _urlunparse(tuple([p.decode("charmap") for p in parts]))
|
||||
- return result.encode("charmap")
|
||||
+from urllib.parse import urljoin, urldefrag
|
||||
+from urllib.parse import urlunparse as _urlunparse
|
||||
|
||||
import zlib
|
||||
from functools import wraps
|
||||
@@ -51,6 +44,12 @@ from twisted.web._newclient import _ensureValidURI, _ensureValidMethod
|
||||
|
||||
|
||||
|
||||
+def urlunparse(parts):
|
||||
+ result = _urlunparse(tuple([p.decode("charmap") for p in parts]))
|
||||
+ return result.encode("charmap")
|
||||
+
|
||||
+
|
||||
+
|
||||
class PartialDownloadError(error.Error):
|
||||
"""
|
||||
Page was only partially downloaded, we got disconnected in middle.
|
||||
diff --git a/src/twisted/web/http.py b/src/twisted/web/http.py
|
||||
index b7afa8b0d..94d0ae81f 100644
|
||||
--- a/src/twisted/web/http.py
|
||||
+++ b/src/twisted/web/http.py
|
||||
@@ -66,27 +66,10 @@ import time
|
||||
import calendar
|
||||
import warnings
|
||||
import os
|
||||
-from io import BytesIO as StringIO
|
||||
-
|
||||
-try:
|
||||
- from urlparse import (
|
||||
- ParseResult as ParseResultBytes, urlparse as _urlparse)
|
||||
- from urllib import unquote
|
||||
- from cgi import parse_header as _parseHeader
|
||||
-except ImportError:
|
||||
- from urllib.parse import (
|
||||
- ParseResultBytes, urlparse as _urlparse, unquote_to_bytes as unquote)
|
||||
-
|
||||
- def _parseHeader(line):
|
||||
- # cgi.parse_header requires a str
|
||||
- key, pdict = cgi.parse_header(line.decode('charmap'))
|
||||
-
|
||||
- # We want the key as bytes, and cgi.parse_multipart (which consumes
|
||||
- # pdict) expects a dict of str keys but bytes values
|
||||
- key = key.encode('charmap')
|
||||
- pdict = {x:y.encode('charmap') for x, y in pdict.items()}
|
||||
- return (key, pdict)
|
||||
+from io import BytesIO
|
||||
|
||||
+from urllib.parse import (
|
||||
+ ParseResultBytes, urlparse as _urlparse, unquote_to_bytes as unquote)
|
||||
|
||||
from zope.interface import Attribute, Interface, implementer, provider
|
||||
|
||||
@@ -163,6 +146,20 @@ monthname = [None,
|
||||
weekdayname_lower = [name.lower() for name in weekdayname]
|
||||
monthname_lower = [name and name.lower() for name in monthname]
|
||||
|
||||
+
|
||||
+
|
||||
+def _parseHeader(line):
|
||||
+ # cgi.parse_header requires a str
|
||||
+ key, pdict = cgi.parse_header(line.decode('charmap'))
|
||||
+
|
||||
+ # We want the key as bytes, and cgi.parse_multipart (which consumes
|
||||
+ # pdict) expects a dict of str keys but bytes values
|
||||
+ key = key.encode('charmap')
|
||||
+ pdict = {x: y.encode('charmap') for x, y in pdict.items()}
|
||||
+ return (key, pdict)
|
||||
+
|
||||
+
|
||||
+
|
||||
def urlparse(url):
|
||||
"""
|
||||
Parse an URL into six components.
|
||||
@@ -486,13 +483,15 @@ class _IDeprecatedHTTPChannelToRequestInterface(Interface):
|
||||
|
||||
class StringTransport:
|
||||
"""
|
||||
- I am a StringIO wrapper that conforms for the transport API. I support
|
||||
+ I am a BytesIO wrapper that conforms for the transport API. I support
|
||||
the `writeSequence' method.
|
||||
"""
|
||||
def __init__(self):
|
||||
- self.s = StringIO()
|
||||
+ self.s = BytesIO()
|
||||
+
|
||||
def writeSequence(self, seq):
|
||||
self.s.write(b''.join(seq))
|
||||
+
|
||||
def __getattr__(self, attr):
|
||||
return getattr(self.__dict__['s'], attr)
|
||||
|
||||
@@ -513,7 +512,7 @@ class HTTPClient(basic.LineReceiver):
|
||||
@type firstLine: C{bool}
|
||||
|
||||
@ivar __buffer: The buffer that stores the response to the HTTP request.
|
||||
- @type __buffer: A C{StringIO} object.
|
||||
+ @type __buffer: A C{BytesIO} object.
|
||||
|
||||
@ivar _header: Part or all of an HTTP request header.
|
||||
@type _header: C{bytes}
|
||||
@@ -579,7 +578,7 @@ class HTTPClient(basic.LineReceiver):
|
||||
if self._header != b"":
|
||||
# Only extract headers if there are any
|
||||
self.extractHeader(self._header)
|
||||
- self.__buffer = StringIO()
|
||||
+ self.__buffer = BytesIO()
|
||||
self.handleEndHeaders()
|
||||
self.setRawMode()
|
||||
return
|
||||
@@ -665,7 +664,7 @@ def _getContentFile(length):
|
||||
Get a writeable file-like object to which request content can be written.
|
||||
"""
|
||||
if length is not None and length < 100000:
|
||||
- return StringIO()
|
||||
+ return BytesIO()
|
||||
return tempfile.TemporaryFile()
|
||||
|
||||
|
||||
diff --git a/src/twisted/web/newsfragments/9801.misc b/src/twisted/web/newsfragments/9801.misc
|
||||
new file mode 100644
|
||||
index 000000000..e69de29bb
|
||||
diff --git a/src/twisted/web/test/test_http.py b/src/twisted/web/test/test_http.py
|
||||
index a3067f732..4189b307c 100644
|
||||
--- a/src/twisted/web/test/test_http.py
|
||||
+++ b/src/twisted/web/test/test_http.py
|
||||
@@ -9,15 +9,11 @@ from __future__ import absolute_import, division
|
||||
|
||||
import base64
|
||||
import calendar
|
||||
-import cgi
|
||||
import random
|
||||
|
||||
import hamcrest
|
||||
|
||||
-try:
|
||||
- from urlparse import urlparse, urlunsplit, clear_cache
|
||||
-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
|
||||
@@ -28,7 +24,7 @@ from zope.interface import (
|
||||
)
|
||||
from zope.interface.verify import verifyObject
|
||||
|
||||
-from twisted.python.compat import (_PY3, iterbytes, long, networkString,
|
||||
+from twisted.python.compat import (iterbytes, long, networkString,
|
||||
unicode, intToBytes)
|
||||
from twisted.python.components import proxyForInterface
|
||||
from twisted.python.failure import Failure
|
||||
@@ -2019,33 +2015,6 @@ Content-Type: application/x-www-form-urlencoded
|
||||
self.assertEqual(content, [networkString(query)])
|
||||
|
||||
|
||||
- def test_missingContentDisposition(self):
|
||||
- """
|
||||
- If the C{Content-Disposition} header is missing, the request is denied
|
||||
- as a bad request.
|
||||
- """
|
||||
- req = b'''\
|
||||
-POST / HTTP/1.0
|
||||
-Content-Type: multipart/form-data; boundary=AaB03x
|
||||
-Content-Length: 103
|
||||
-
|
||||
---AaB03x
|
||||
-Content-Type: text/plain
|
||||
-Content-Transfer-Encoding: quoted-printable
|
||||
-
|
||||
-abasdfg
|
||||
---AaB03x--
|
||||
-'''
|
||||
- channel = self.runRequest(req, http.Request, success=False)
|
||||
- self.assertEqual(
|
||||
- channel.transport.value(),
|
||||
- b"HTTP/1.1 400 Bad Request\r\n\r\n")
|
||||
-
|
||||
- if _PY3:
|
||||
- test_missingContentDisposition.skip = (
|
||||
- "cgi.parse_multipart is much more error-tolerant on Python 3.")
|
||||
-
|
||||
-
|
||||
def test_multipartProcessingFailure(self):
|
||||
"""
|
||||
When the multipart processing fails the client gets a 400 Bad Request.
|
||||
@@ -2373,15 +2342,15 @@ ok
|
||||
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/src/twisted/web/test/test_webclient.py b/src/twisted/web/test/test_webclient.py
|
||||
index 680e02780..672594993 100644
|
||||
--- a/src/twisted/web/test/test_webclient.py
|
||||
+++ b/src/twisted/web/test/test_webclient.py
|
||||
@@ -11,10 +11,7 @@ import io
|
||||
import os
|
||||
from errno import ENOSPC
|
||||
|
||||
-try:
|
||||
- from urlparse import urlparse, urljoin
|
||||
-except ImportError:
|
||||
- from urllib.parse import urlparse, urljoin
|
||||
+from urllib.parse import urlparse, urljoin
|
||||
|
||||
from twisted.python.compat import networkString, nativeString, intToBytes
|
||||
from twisted.trial import unittest, util
|
||||
--
|
||||
2.26.2
|
||||
|
||||
@@ -1,94 +0,0 @@
|
||||
From 653fb2aea0ca1f60558917d52f4ff0c33cd7b067 Mon Sep 17 00:00:00 2001
|
||||
From: Craig Rodrigues <rodrigc@crodrigues.org>
|
||||
Date: Sun, 12 Apr 2020 14:28:23 -0700
|
||||
Subject: [PATCH 1/2] Add digestmod parameter to HMAC.__init__() invocations
|
||||
|
||||
This parameter is now required on Python 3.8+
|
||||
---
|
||||
src/twisted/cred/credentials.py | 3 ++-
|
||||
src/twisted/cred/test/test_cramauth.py | 11 ++++++++---
|
||||
src/twisted/mail/test/test_pop3.py | 4 +++-
|
||||
3 files changed, 13 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/src/twisted/cred/credentials.py b/src/twisted/cred/credentials.py
|
||||
index 5469e5158..67c24cb01 100644
|
||||
--- a/src/twisted/cred/credentials.py
|
||||
+++ b/src/twisted/cred/credentials.py
|
||||
@@ -441,7 +441,8 @@ class CramMD5Credentials(object):
|
||||
|
||||
|
||||
def checkPassword(self, password):
|
||||
- verify = hexlify(hmac.HMAC(password, self.challenge).digest())
|
||||
+ verify = hexlify(hmac.HMAC(password, self.challenge,
|
||||
+ digestmod=md5).digest())
|
||||
return verify == self.response
|
||||
|
||||
|
||||
diff --git a/src/twisted/cred/test/test_cramauth.py b/src/twisted/cred/test/test_cramauth.py
|
||||
index 1ee08712b..d21f2f68c 100644
|
||||
--- a/src/twisted/cred/test/test_cramauth.py
|
||||
+++ b/src/twisted/cred/test/test_cramauth.py
|
||||
@@ -7,6 +7,8 @@ Tests for L{twisted.cred}'s implementation of CRAM-MD5.
|
||||
|
||||
from __future__ import division, absolute_import
|
||||
|
||||
+import hashlib
|
||||
+
|
||||
from hmac import HMAC
|
||||
from binascii import hexlify
|
||||
|
||||
@@ -39,7 +41,8 @@ class CramMD5CredentialsTests(TestCase):
|
||||
"""
|
||||
c = CramMD5Credentials()
|
||||
chal = c.getChallenge()
|
||||
- c.response = hexlify(HMAC(b'secret', chal).digest())
|
||||
+ c.response = hexlify(HMAC(b'secret', chal,
|
||||
+ digestmod=hashlib.md5).digest())
|
||||
self.assertTrue(c.checkPassword(b'secret'))
|
||||
|
||||
|
||||
@@ -61,7 +64,8 @@ class CramMD5CredentialsTests(TestCase):
|
||||
"""
|
||||
c = CramMD5Credentials()
|
||||
chal = c.getChallenge()
|
||||
- c.response = hexlify(HMAC(b'thewrongsecret', chal).digest())
|
||||
+ c.response = hexlify(HMAC(b'thewrongsecret', chal,
|
||||
+ digestmod=hashlib.md5).digest())
|
||||
self.assertFalse(c.checkPassword(b'secret'))
|
||||
|
||||
|
||||
@@ -75,7 +79,8 @@ class CramMD5CredentialsTests(TestCase):
|
||||
chal = c.getChallenge()
|
||||
c.setResponse(b" ".join(
|
||||
(b"squirrel",
|
||||
- hexlify(HMAC(b'supersecret', chal).digest()))))
|
||||
+ hexlify(HMAC(b'supersecret', chal,
|
||||
+ digestmod=hashlib.md5).digest()))))
|
||||
self.assertTrue(c.checkPassword(b'supersecret'))
|
||||
self.assertEqual(c.username, b"squirrel")
|
||||
|
||||
diff --git a/src/twisted/mail/test/test_pop3.py b/src/twisted/mail/test/test_pop3.py
|
||||
index 4a59c3b49..ea513487c 100644
|
||||
--- a/src/twisted/mail/test/test_pop3.py
|
||||
+++ b/src/twisted/mail/test/test_pop3.py
|
||||
@@ -11,6 +11,7 @@ import hmac
|
||||
import base64
|
||||
import itertools
|
||||
|
||||
+from hashlib import md5
|
||||
from collections import OrderedDict
|
||||
from io import BytesIO
|
||||
|
||||
@@ -1097,7 +1098,8 @@ class SASLTests(unittest.TestCase):
|
||||
p.lineReceived(b"AUTH CRAM-MD5")
|
||||
chal = s.getvalue().splitlines()[-1][2:]
|
||||
chal = base64.decodestring(chal)
|
||||
- response = hmac.HMAC(b'testpassword', chal).hexdigest().encode("ascii")
|
||||
+ response = hmac.HMAC(b'testpassword', chal,
|
||||
+ digestmod=md5).hexdigest().encode("ascii")
|
||||
|
||||
p.lineReceived(
|
||||
base64.encodestring(b'testuser ' + response).rstrip(b'\n'))
|
||||
--
|
||||
2.26.2
|
||||
|
||||
@@ -1,158 +0,0 @@
|
||||
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
|
||||
@@ -1,115 +0,0 @@
|
||||
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
|
||||
|
||||
@@ -1,194 +0,0 @@
|
||||
# Copyright 1999-2021 Gentoo Authors
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
|
||||
EAPI=7
|
||||
|
||||
PYTHON_COMPAT=( python3_{7,8,9} )
|
||||
PYTHON_REQ_USE="threads(+)"
|
||||
|
||||
inherit distutils-r1 virtualx
|
||||
|
||||
TWISTED_PN="Twisted"
|
||||
TWISTED_P="${TWISTED_PN}-${PV}"
|
||||
TWISTED_RELEASE=$(ver_cut 1-2)
|
||||
|
||||
DESCRIPTION="An asynchronous networking framework written in Python"
|
||||
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 hppa ~ia64 ~mips ppc ppc64 ~s390 sparc x86 ~amd64-linux ~x86-linux"
|
||||
|
||||
LICENSE="MIT"
|
||||
SLOT="0"
|
||||
IUSE="conch crypt http2 serial test"
|
||||
RESTRICT="!test? ( test )"
|
||||
|
||||
RDEPEND="
|
||||
>=dev-python/attrs-17.4.0[${PYTHON_USEDEP}]
|
||||
>=dev-python/automat-0.3.0[${PYTHON_USEDEP}]
|
||||
>=dev-python/constantly-15.1.0[${PYTHON_USEDEP}]
|
||||
>=dev-python/hyperlink-17.1.1[${PYTHON_USEDEP}]
|
||||
>=dev-python/incremental-16.10.1[${PYTHON_USEDEP}]
|
||||
>=dev-python/pyhamcrest-1.9.0[${PYTHON_USEDEP}]
|
||||
>=dev-python/zope-interface-4.4.2[${PYTHON_USEDEP}]
|
||||
conch? (
|
||||
dev-python/pyasn1[${PYTHON_USEDEP}]
|
||||
>=dev-python/cryptography-1.5.0[${PYTHON_USEDEP}]
|
||||
>=dev-python/appdirs-1.4.0[${PYTHON_USEDEP}]
|
||||
)
|
||||
crypt? (
|
||||
>=dev-python/pyopenssl-16.0.0[${PYTHON_USEDEP}]
|
||||
dev-python/service_identity[${PYTHON_USEDEP}]
|
||||
>=dev-python/idna-0.6[${PYTHON_USEDEP}]
|
||||
)
|
||||
serial? ( >=dev-python/pyserial-3.0[${PYTHON_USEDEP}] )
|
||||
http2? (
|
||||
>=dev-python/hyper-h2-3.0.0[${PYTHON_USEDEP}]
|
||||
<dev-python/hyper-h2-4.0.0[${PYTHON_USEDEP}]
|
||||
>=dev-python/priority-1.1.0[${PYTHON_USEDEP}]
|
||||
<dev-python/priority-2.0[${PYTHON_USEDEP}]
|
||||
)
|
||||
!dev-python/twisted-core
|
||||
!dev-python/twisted-conch
|
||||
!dev-python/twisted-lore
|
||||
!dev-python/twisted-mail
|
||||
!dev-python/twisted-names
|
||||
!dev-python/twisted-news
|
||||
!dev-python/twisted-pair
|
||||
!dev-python/twisted-runner
|
||||
!dev-python/twisted-words
|
||||
!dev-python/twisted-web
|
||||
"
|
||||
DEPEND="
|
||||
dev-python/bcrypt
|
||||
>=dev-python/incremental-16.10.1[${PYTHON_USEDEP}]
|
||||
test? (
|
||||
dev-python/gmpy[${PYTHON_USEDEP}]
|
||||
dev-python/pyasn1[${PYTHON_USEDEP}]
|
||||
>=dev-python/cryptography-0.9.1[${PYTHON_USEDEP}]
|
||||
>=dev-python/appdirs-1.4.0[${PYTHON_USEDEP}]
|
||||
>=dev-python/pyopenssl-0.13[${PYTHON_USEDEP}]
|
||||
dev-python/service_identity[${PYTHON_USEDEP}]
|
||||
dev-python/idna[${PYTHON_USEDEP}]
|
||||
dev-python/pyserial[${PYTHON_USEDEP}]
|
||||
>=dev-python/constantly-15.1.0[${PYTHON_USEDEP}]
|
||||
net-misc/openssh
|
||||
)
|
||||
"
|
||||
|
||||
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
|
||||
|
||||
# Conch doesn't work with latest >=OpenSSH 7.6
|
||||
# - https://twistedmatrix.com/trac/ticket/9311
|
||||
# - https://twistedmatrix.com/trac/ticket/9515
|
||||
rm src/twisted/conch/test/test_ckeygen.py || die
|
||||
rm src/twisted/conch/test/test_conch.py || die
|
||||
rm src/twisted/conch/test/test_cftp.py || die
|
||||
|
||||
# puts system in EMFILE state, then the exception handler may fail
|
||||
# trying to open more files due to some gi magic
|
||||
sed -e '/SKIP_EMFILE/s:None:"Fails on non-pristine systems":' \
|
||||
-i src/twisted/internet/test/test_tcp.py || die
|
||||
|
||||
# TODO: times out, i can't find where to increase the timeout
|
||||
sed -e 's:test_manyProcesses:_&:' \
|
||||
-i src/twisted/test/test_process.py || die
|
||||
|
||||
# multicast tests fail within network-sandbox
|
||||
sed -e 's:test_joinLeave:_&:' \
|
||||
-e 's:test_loopback:_&:' \
|
||||
-e 's:test_multiListen:_&:' \
|
||||
-e 's:test_multicast:_&:' \
|
||||
-i src/twisted/test/test_udp.py || die
|
||||
|
||||
# accesses /dev/net/tun
|
||||
sed -e '/class RealDeviceTestsMixin/a\
|
||||
skip = "Requires extra permissions"' \
|
||||
-i src/twisted/pair/test/test_tuntap.py || die
|
||||
|
||||
# TODO: figure it out, probably doesn't accept DST date here
|
||||
sed -e 's:test_getTimezoneOffsetWithoutDaylightSavingTime:_&:' \
|
||||
-i src/twisted/test/test_log.py || die
|
||||
|
||||
# TODO: failures specific to Python 2
|
||||
sed -e 's:testLookupProcNetTcp:_&:' \
|
||||
-i src/twisted/test/test_ident.py || die
|
||||
sed -e 's:test_loggingFactoryOpensLogfileAutomatically:_&:' \
|
||||
-i src/twisted/test/test_policies.py || die
|
||||
|
||||
distutils-r1_python_prepare_all
|
||||
}
|
||||
|
||||
src_test() {
|
||||
virtx distutils-r1_src_test
|
||||
}
|
||||
|
||||
python_test() {
|
||||
# TODO: upstream seems to override our build paths
|
||||
distutils_install_for_testing
|
||||
|
||||
"${EPYTHON}" -m twisted.trial twisted ||
|
||||
die "Tests failed with ${EPYTHON}"
|
||||
}
|
||||
|
||||
python_install() {
|
||||
distutils-r1_python_install
|
||||
|
||||
cd "${D}$(python_get_sitedir)" || die
|
||||
|
||||
# own the dropin.cache so we don't leave orphans
|
||||
touch twisted/plugins/dropin.cache || die
|
||||
|
||||
python_doscript "${WORKDIR}"/twisted-regen-cache
|
||||
}
|
||||
|
||||
python_install_all() {
|
||||
distutils-r1_python_install_all
|
||||
|
||||
newconfd "${FILESDIR}/twistd.conf" twistd
|
||||
newinitd "${FILESDIR}/twistd.init" twistd
|
||||
}
|
||||
|
||||
python_postinst() {
|
||||
twisted-regen-cache || die
|
||||
}
|
||||
|
||||
pkg_postinst() {
|
||||
python_foreach_impl python_postinst
|
||||
|
||||
einfo "Install complete"
|
||||
if use test ; then
|
||||
einfo ""
|
||||
einfo "Some tests have been disabled during testing due to"
|
||||
einfo "known incompatibilities with the emerge sandboxes and/or"
|
||||
einfo "not runnable as the root user."
|
||||
einfo "For a complete test suite run on the code."
|
||||
einfo "Run the tests as a normal user for each python it is installed to."
|
||||
einfo " ie: $ python3.6 /usr/bin/trial twisted"
|
||||
fi
|
||||
}
|
||||
|
||||
python_postrm() {
|
||||
rm -f "${ROOT}$(python_get_sitedir)/twisted/plugins/dropin.cache" || die
|
||||
}
|
||||
|
||||
pkg_postrm() {
|
||||
# if we're removing the last version, remove the cache file
|
||||
if [[ ! ${REPLACING_VERSIONS} ]]; then
|
||||
python_foreach_impl python_postrm
|
||||
fi
|
||||
}
|
||||
@@ -1,190 +0,0 @@
|
||||
# Copyright 1999-2021 Gentoo Authors
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
|
||||
EAPI=7
|
||||
|
||||
PYTHON_COMPAT=( python3_{7,8,9} )
|
||||
PYTHON_REQ_USE="threads(+)"
|
||||
|
||||
inherit distutils-r1 virtualx
|
||||
|
||||
TWISTED_PN="Twisted"
|
||||
TWISTED_P="${TWISTED_PN}-${PV}"
|
||||
TWISTED_RELEASE=$(ver_cut 1-2)
|
||||
|
||||
DESCRIPTION="An asynchronous networking framework written in Python"
|
||||
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"
|
||||
|
||||
KEYWORDS="~alpha amd64 arm arm64 ~ia64 ~mips ppc ppc64 ~riscv ~s390 sparc x86 ~amd64-linux ~x86-linux ~x64-macos"
|
||||
|
||||
LICENSE="MIT"
|
||||
SLOT="0"
|
||||
IUSE="conch crypt http2 serial test"
|
||||
RESTRICT="!test? ( test )"
|
||||
|
||||
RDEPEND="
|
||||
>=dev-python/attrs-19.2.0[${PYTHON_USEDEP}]
|
||||
>=dev-python/automat-0.3.0[${PYTHON_USEDEP}]
|
||||
>=dev-python/constantly-15.1.0[${PYTHON_USEDEP}]
|
||||
>=dev-python/hyperlink-17.1.1[${PYTHON_USEDEP}]
|
||||
>=dev-python/incremental-16.10.1[${PYTHON_USEDEP}]
|
||||
>=dev-python/pyhamcrest-1.9.0[${PYTHON_USEDEP}]
|
||||
>=dev-python/zope-interface-4.4.2[${PYTHON_USEDEP}]
|
||||
conch? (
|
||||
dev-python/pyasn1[${PYTHON_USEDEP}]
|
||||
>=dev-python/cryptography-1.5.0[${PYTHON_USEDEP}]
|
||||
>=dev-python/appdirs-1.4.0[${PYTHON_USEDEP}]
|
||||
)
|
||||
crypt? (
|
||||
>=dev-python/pyopenssl-16.0.0[${PYTHON_USEDEP}]
|
||||
dev-python/service_identity[${PYTHON_USEDEP}]
|
||||
>=dev-python/idna-0.6[${PYTHON_USEDEP}]
|
||||
)
|
||||
serial? ( >=dev-python/pyserial-3.0[${PYTHON_USEDEP}] )
|
||||
http2? (
|
||||
>=dev-python/hyper-h2-3.0.0[${PYTHON_USEDEP}]
|
||||
<dev-python/hyper-h2-4.0.0[${PYTHON_USEDEP}]
|
||||
>=dev-python/priority-1.1.0[${PYTHON_USEDEP}]
|
||||
<dev-python/priority-2.0[${PYTHON_USEDEP}]
|
||||
)
|
||||
!dev-python/twisted-core
|
||||
!dev-python/twisted-conch
|
||||
!dev-python/twisted-lore
|
||||
!dev-python/twisted-mail
|
||||
!dev-python/twisted-names
|
||||
!dev-python/twisted-news
|
||||
!dev-python/twisted-pair
|
||||
!dev-python/twisted-runner
|
||||
!dev-python/twisted-words
|
||||
!dev-python/twisted-web
|
||||
"
|
||||
DEPEND="
|
||||
dev-python/bcrypt
|
||||
>=dev-python/incremental-16.10.1[${PYTHON_USEDEP}]
|
||||
test? (
|
||||
dev-python/gmpy[${PYTHON_USEDEP}]
|
||||
dev-python/pyasn1[${PYTHON_USEDEP}]
|
||||
>=dev-python/cryptography-0.9.1[${PYTHON_USEDEP}]
|
||||
>=dev-python/appdirs-1.4.0[${PYTHON_USEDEP}]
|
||||
>=dev-python/pyopenssl-0.13[${PYTHON_USEDEP}]
|
||||
dev-python/service_identity[${PYTHON_USEDEP}]
|
||||
dev-python/idna[${PYTHON_USEDEP}]
|
||||
dev-python/pyserial[${PYTHON_USEDEP}]
|
||||
>=dev-python/constantly-15.1.0[${PYTHON_USEDEP}]
|
||||
net-misc/openssh
|
||||
)
|
||||
"
|
||||
|
||||
S=${WORKDIR}/${TWISTED_P}
|
||||
|
||||
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
|
||||
# sphinx (including on py2)
|
||||
rm src/twisted/python/test/test_release.py || die
|
||||
|
||||
# Conch doesn't work with latest >=OpenSSH 7.6
|
||||
# - https://twistedmatrix.com/trac/ticket/9311
|
||||
# - https://twistedmatrix.com/trac/ticket/9515
|
||||
rm src/twisted/conch/test/test_ckeygen.py || die
|
||||
rm src/twisted/conch/test/test_conch.py || die
|
||||
rm src/twisted/conch/test/test_cftp.py || die
|
||||
|
||||
# puts system in EMFILE state, then the exception handler may fail
|
||||
# trying to open more files due to some gi magic
|
||||
sed -e '/SKIP_EMFILE/s:None:"Fails on non-pristine systems":' \
|
||||
-i src/twisted/internet/test/test_tcp.py || die
|
||||
|
||||
# multicast tests fail within network-sandbox
|
||||
sed -e 's:test_joinLeave:_&:' \
|
||||
-e 's:test_loopback:_&:' \
|
||||
-e 's:test_multiListen:_&:' \
|
||||
-e 's:test_multicast:_&:' \
|
||||
-i src/twisted/test/test_udp.py || die
|
||||
|
||||
# accesses /dev/net/tun
|
||||
sed -e '/class RealDeviceTestsMixin/a\
|
||||
skip = "Requires extra permissions"' \
|
||||
-i src/twisted/pair/test/test_tuntap.py || die
|
||||
|
||||
# TODO: figure it out, probably doesn't accept DST date here
|
||||
sed -e 's:test_getTimezoneOffsetWithoutDaylightSavingTime:_&:' \
|
||||
-i src/twisted/test/test_log.py || die
|
||||
|
||||
# TODO: failures specific to Python 2
|
||||
sed -e 's:testLookupProcNetTcp:_&:' \
|
||||
-i src/twisted/test/test_ident.py || die
|
||||
sed -e 's:test_loggingFactoryOpensLogfileAutomatically:_&:' \
|
||||
-i src/twisted/test/test_policies.py || die
|
||||
|
||||
distutils-r1_python_prepare_all
|
||||
}
|
||||
|
||||
src_test() {
|
||||
virtx distutils-r1_src_test
|
||||
}
|
||||
|
||||
python_test() {
|
||||
# TODO: upstream seems to override our build paths
|
||||
distutils_install_for_testing
|
||||
|
||||
"${EPYTHON}" -m twisted.trial twisted ||
|
||||
die "Tests failed with ${EPYTHON}"
|
||||
}
|
||||
|
||||
python_install() {
|
||||
distutils-r1_python_install
|
||||
|
||||
cd "${D}$(python_get_sitedir)" || die
|
||||
|
||||
# own the dropin.cache so we don't leave orphans
|
||||
touch twisted/plugins/dropin.cache || die
|
||||
|
||||
python_doscript "${WORKDIR}"/twisted-regen-cache
|
||||
}
|
||||
|
||||
python_install_all() {
|
||||
distutils-r1_python_install_all
|
||||
|
||||
newconfd "${FILESDIR}/twistd.conf" twistd
|
||||
newinitd "${FILESDIR}/twistd.init" twistd
|
||||
}
|
||||
|
||||
python_postinst() {
|
||||
twisted-regen-cache || die
|
||||
}
|
||||
|
||||
pkg_postinst() {
|
||||
python_foreach_impl python_postinst
|
||||
|
||||
einfo "Install complete"
|
||||
if use test ; then
|
||||
einfo ""
|
||||
einfo "Some tests have been disabled during testing due to"
|
||||
einfo "known incompatibilities with the emerge sandboxes and/or"
|
||||
einfo "not runnable as the root user."
|
||||
einfo "For a complete test suite run on the code."
|
||||
einfo "Run the tests as a normal user for each python it is installed to."
|
||||
einfo " ie: $ python3.6 /usr/bin/trial twisted"
|
||||
fi
|
||||
}
|
||||
|
||||
python_postrm() {
|
||||
rm -f "${ROOT}$(python_get_sitedir)/twisted/plugins/dropin.cache" || die
|
||||
}
|
||||
|
||||
pkg_postrm() {
|
||||
# if we're removing the last version, remove the cache file
|
||||
if [[ ! ${REPLACING_VERSIONS} ]]; then
|
||||
python_foreach_impl python_postrm
|
||||
fi
|
||||
}
|
||||
Reference in New Issue
Block a user