Skip to content

Commit a38c774

Browse files
committed
Drop six module usage
It was used for Python 2 backward compatibility. No longer needed.
1 parent cc2d2bf commit a38c774

7 files changed

Lines changed: 10 additions & 15 deletions

File tree

api/utils.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33

4-
import six
54
from . import global_
65
from . import errmsg
76

@@ -22,8 +21,6 @@ def read_txt_file(fname):
2221
for i in encodings:
2322
try:
2423
result = content.decode(i)
25-
if six.PY2:
26-
result = result.encode('utf-8')
2724
return result
2825
except UnicodeDecodeError:
2926
pass
@@ -40,7 +37,7 @@ def open_file(fname, mode='rb', encoding='utf-8'):
4037
:param encoding: optional encoding (string). Ignored in python2 or if not in text mode
4138
:return: an open file handle
4239
"""
43-
if six.PY2 or 't' not in mode:
40+
if 't' not in mode:
4441
kwargs = {}
4542
else:
4643
kwargs = {'encoding': encoding}

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
ply==3.11
2-
six
32

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,6 @@ def get_files(folders):
6868
'Programming Language :: Python :: 3.5',
6969
'Programming Language :: Python :: 3.6',
7070
],
71-
install_requires=['six', 'ply'],
71+
install_requires=['ply'],
7272
tags=['BASIC', 'zxspectrum', 'compiler', 'z80']
7373
)

symbols/string_.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
# the GNU General License
1010
# ----------------------------------------------------------------------
1111

12-
import six
13-
1412
from api.constants import CLASS
1513
from .symbol_ import Symbol
1614
from .type_ import Type
@@ -44,21 +42,21 @@ def __repr__(self):
4442
return '"%s"' % str(self)
4543

4644
def __eq__(self, other):
47-
if isinstance(other, six.string_types):
45+
if isinstance(other, str):
4846
return self.value == other
4947

5048
assert isinstance(other, SymbolSTRING)
5149
return self.value == other.value
5250

5351
def __gt__(self, other):
54-
if type(other) in six.string_types:
52+
if isinstance(other, str):
5553
return self.value > other
5654

5755
assert isinstance(other, SymbolSTRING)
5856
return self.value > other.value
5957

6058
def __lt__(self, other):
61-
if type(other) in six.string_types:
59+
if isinstance(other, str):
6260
return self.value < other
6361

6462
assert isinstance(other, SymbolSTRING)

tests/functional/test_.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
# vim:ts=4:et:ai
33

44
import sys
5-
import six
65
import os
76
import doctest
87
import test
98

9+
from io import StringIO
1010

11-
class OutputProxy(six.StringIO):
11+
12+
class OutputProxy(StringIO):
1213
"""A simple interface to replace sys.stdout so
1314
doctest can capture it.
1415
"""

zxb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import re
1010
import argparse
1111

12-
from six import StringIO
12+
from io import StringIO
1313

1414
import api.debug
1515
import api.config

zxblex.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ def is_label(token):
677677
return column == 1
678678

679679

680-
lexer = lex.lex(lextab='parsetab.zxblextab')
680+
lexer = lex.lex()
681681

682682
if __name__ == '__main__': # For testing purposes
683683
lexer.input(open(sys.argv[1], 'rt').read())

0 commit comments

Comments
 (0)