Skip to content

Commit 08f48d5

Browse files
author
Jussi Kukkonen
authored
Merge pull request #1340 from avelichka/remove-six
Remove use of six
2 parents cd39bff + d8b3554 commit 08f48d5

33 files changed

+99
-127
lines changed

pylintrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ ignore-on-opaque-inference=yes
287287
# List of class names for which member attributes should not be checked (useful
288288
# for classes with dynamically set attributes). This supports the use of
289289
# qualified names.
290-
ignored-classes=optparse.Values,thread._local,_thread._local, six.moves
290+
ignored-classes=optparse.Values,thread._local,_thread._local
291291

292292
# List of module names for which member attributes should not be checked
293293
# (useful for modules/projects where namespaces are manipulated during runtime
@@ -334,7 +334,7 @@ init-import=no
334334

335335
# List of qualified module names which can have objects that can redefine
336336
# builtins.
337-
redefining-builtins-modules=six.moves,future.builtins
337+
redefining-builtins-modules=future.builtins
338338

339339

340340
[CLASSES]

requirements-pinned.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@ pycparser==2.20 # via cffi
77
pynacl==1.4.0 # via securesystemslib
88
requests==2.25.1
99
securesystemslib[crypto,pynacl]==0.20.0
10-
six==1.15.0
1110
urllib3==1.26.4 # via requests

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,3 @@
4343
#
4444
securesystemslib[crypto, pynacl]
4545
requests
46-
six

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,7 @@
113113
python_requires="~=3.6",
114114
install_requires = [
115115
'requests>=2.19.1',
116-
'securesystemslib>=0.20.0',
117-
'six>=1.11.0'
116+
'securesystemslib>=0.20.0'
118117
],
119118
packages = find_packages(exclude=['tests']),
120119
scripts = [

tests/simple_https_server.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
import sys
4141
import ssl
4242
import os
43-
import six
43+
import http.server
4444

4545
keyfile = os.path.join('ssl_certs', 'ssl_cert.key')
4646
certfile = os.path.join('ssl_certs', 'ssl_cert.crt')
@@ -49,8 +49,8 @@
4949
if len(sys.argv) > 1 and os.path.exists(sys.argv[1]):
5050
certfile = sys.argv[1]
5151

52-
httpd = six.moves.BaseHTTPServer.HTTPServer(('localhost', 0),
53-
six.moves.SimpleHTTPServer.SimpleHTTPRequestHandler)
52+
httpd = http.server.HTTPServer(('localhost', 0),
53+
http.server.SimpleHTTPRequestHandler)
5454

5555
httpd.socket = ssl.wrap_socket(
5656
httpd.socket, keyfile=keyfile, certfile=certfile, server_side=True)

tests/simple_server.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@
3535

3636
import sys
3737
import random
38-
39-
import six
40-
from six.moves.SimpleHTTPServer import SimpleHTTPRequestHandler
38+
import socketserver
39+
from http.server import SimpleHTTPRequestHandler
4140

4241

4342
class QuietHTTPRequestHandler(SimpleHTTPRequestHandler):
@@ -64,9 +63,9 @@ def log_request(self, code='-', size='-'):
6463

6564
# Allow re-use so you can re-run tests as often as you want even if the
6665
# tests re-use ports. Otherwise TCP TIME-WAIT prevents reuse for ~1 minute
67-
six.moves.socketserver.TCPServer.allow_reuse_address = True
66+
socketserver.TCPServer.allow_reuse_address = True
6867

69-
httpd = six.moves.socketserver.TCPServer(('localhost', 0), handler)
68+
httpd = socketserver.TCPServer(('localhost', 0), handler)
7069
port_message = 'bind succeeded, server port is: ' \
7170
+ str(httpd.server_address[1])
7271
print(port_message)

tests/slow_retrieval_server.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,12 @@
3232
import os
3333
import sys
3434
import time
35-
36-
import six
35+
import http.server
3736

3837

3938

4039
# HTTP request handler.
41-
class Handler(six.moves.BaseHTTPServer.BaseHTTPRequestHandler):
40+
class Handler(http.server.BaseHTTPRequestHandler):
4241

4342
# Overwrite do_GET.
4443
def do_GET(self):
@@ -66,7 +65,7 @@ def do_GET(self):
6665
if __name__ == '__main__':
6766
server_address = ('localhost', 0)
6867

69-
httpd = six.moves.BaseHTTPServer.HTTPServer(server_address, Handler)
68+
httpd = http.server.HTTPServer(server_address, Handler)
7069
port_message = 'bind succeeded, server port is: ' \
7170
+ str(httpd.server_address[1])
7271
print(port_message)

tests/test_arbitrary_package_attack.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import logging
4444
import unittest
4545
import sys
46+
from urllib import request
4647

4748
import tuf
4849
import tuf.formats
@@ -55,7 +56,6 @@
5556
from tests import utils
5657

5758
import securesystemslib
58-
import six
5959

6060
logger = logging.getLogger(__name__)
6161

@@ -174,7 +174,7 @@ def test_without_tuf(self):
174174
url_file = os.path.join(url_prefix, 'targets', 'file1.txt')
175175

176176
# On Windows, the URL portion should not contain back slashes.
177-
six.moves.urllib.request.urlretrieve(url_file.replace('\\', '/'), client_target_path)
177+
request.urlretrieve(url_file.replace('\\', '/'), client_target_path)
178178

179179
self.assertTrue(os.path.exists(client_target_path))
180180
length, hashes = securesystemslib.util.get_file_details(client_target_path)
@@ -188,7 +188,7 @@ def test_without_tuf(self):
188188
malicious_fileinfo = tuf.formats.make_targets_fileinfo(length, hashes)
189189

190190
# On Windows, the URL portion should not contain back slashes.
191-
six.moves.urllib.request.urlretrieve(url_file.replace('\\', '/'), client_target_path)
191+
request.urlretrieve(url_file.replace('\\', '/'), client_target_path)
192192

193193
length, hashes = securesystemslib.util.get_file_details(client_target_path)
194194
download_fileinfo = tuf.formats.make_targets_fileinfo(length, hashes)

tests/test_endless_data_attack.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import logging
4747
import unittest
4848
import sys
49+
from urllib import request
4950

5051
import tuf
5152
import tuf.formats
@@ -57,7 +58,6 @@
5758
from tests import utils
5859

5960
import securesystemslib
60-
import six
6161

6262
logger = logging.getLogger(__name__)
6363

@@ -176,7 +176,7 @@ def test_without_tuf(self):
176176
url_file = os.path.join(url_prefix, 'targets', 'file1.txt')
177177

178178
# On Windows, the URL portion should not contain backslashes.
179-
six.moves.urllib.request.urlretrieve(url_file.replace('\\', '/'), client_target_path)
179+
request.urlretrieve(url_file.replace('\\', '/'), client_target_path)
180180

181181
self.assertTrue(os.path.exists(client_target_path))
182182
length, hashes = securesystemslib.util.get_file_details(client_target_path)
@@ -194,7 +194,7 @@ def test_without_tuf(self):
194194
self.assertTrue(large_length > length)
195195

196196
# On Windows, the URL portion should not contain backslashes.
197-
six.moves.urllib.request.urlretrieve(url_file.replace('\\', '/'), client_target_path)
197+
request.urlretrieve(url_file.replace('\\', '/'), client_target_path)
198198

199199
length, hashes = securesystemslib.util.get_file_details(client_target_path)
200200
download_fileinfo = tuf.formats.make_targets_fileinfo(length, hashes)
@@ -269,7 +269,7 @@ def test_with_tuf(self):
269269
self.repository_updater.refresh()
270270

271271
except tuf.exceptions.NoWorkingMirrorError as exception:
272-
for mirror_url, mirror_error in six.iteritems(exception.mirror_errors):
272+
for mirror_url, mirror_error in exception.mirror_errors.items():
273273
self.assertTrue(isinstance(mirror_error, securesystemslib.exceptions.Error))
274274

275275
else:

tests/test_extraneous_dependencies_attack.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
from tests import utils
6161

6262
import securesystemslib
63-
import six
6463

6564
logger = logging.getLogger(__name__)
6665

@@ -206,7 +205,7 @@ def test_with_tuf(self):
206205
# Verify that the specific 'tuf.exceptions.ForbiddenTargetError' exception is raised
207206
# by each mirror.
208207
except tuf.exceptions.NoWorkingMirrorError as exception:
209-
for mirror_url, mirror_error in six.iteritems(exception.mirror_errors):
208+
for mirror_url, mirror_error in exception.mirror_errors.items():
210209
url_prefix = self.repository_mirrors['mirror1']['url_prefix']
211210
url_file = os.path.join(url_prefix, 'metadata', 'role1.json')
212211

0 commit comments

Comments
 (0)