diff --git a/dev_scripts/pylint_plugins.py b/dev_scripts/pylint_plugins.py index 8d6f87cc..73611421 100644 --- a/dev_scripts/pylint_plugins.py +++ b/dev_scripts/pylint_plugins.py @@ -32,17 +32,11 @@ def transform(mod): if b'pylint:' in text[0]: msg = 'pylint directive found on the first line of {}; please move to below copyright header' raise RuntimeError(msg.format(mod.name)) - if sys.version_info[0] == 3: - char = chr(text[0][0]) - else: - char = text[0][0] + char = chr(text[0][0]) if text[0].strip() and char != '#': msg = 'first line of {} is not a comment; is the copyright header missing?' raise RuntimeError(msg.format(mod.name)) - if sys.version_info[0] == 3: - text[0] = '# pylint: disable={}'.format(','.join(errors)).encode('utf-8') - else: - text[0] = '# pylint: disable={}'.format(','.join(errors)) + text[0] = '# pylint: disable={}'.format(','.join(errors)).encode('utf-8') mod.file_bytes = b'\n'.join(text) # This is what *should* happen, but doesn't work. diff --git a/wa/commands/revent.py b/wa/commands/revent.py index 87363122..ab46f7e6 100644 --- a/wa/commands/revent.py +++ b/wa/commands/revent.py @@ -25,10 +25,6 @@ from wa.framework.target.manager import TargetManager from wa.utils.revent import ReventRecorder -if sys.version_info[0] == 3: - raw_input = input # pylint: disable=redefined-builtin - - class RecordCommand(Command): name = 'record' @@ -137,11 +133,11 @@ class RecordCommand(Command): def record(self, revent_file, name, output_path): msg = 'Press Enter when you are ready to record {}...' self.logger.info(msg.format(name)) - raw_input('') + input('') self.revent_recorder.start_record(revent_file) msg = 'Press Enter when you have finished recording {}...' self.logger.info(msg.format(name)) - raw_input('') + input('') self.revent_recorder.stop_record() if not os.path.isdir(output_path): diff --git a/wa/commands/show.py b/wa/commands/show.py index 45531a4c..071b627e 100644 --- a/wa/commands/show.py +++ b/wa/commands/show.py @@ -73,11 +73,8 @@ class ShowCommand(Command): if which('pandoc'): p = Popen(['pandoc', '-f', 'rst', '-t', 'man'], stdin=PIPE, stdout=PIPE, stderr=PIPE) - if sys.version_info[0] == 3: - output, _ = p.communicate(rst_output.encode(sys.stdin.encoding)) - output = output.decode(sys.stdout.encoding) - else: - output, _ = p.communicate(rst_output) + output, _ = p.communicate(rst_output.encode(sys.stdin.encoding)) + output = output.decode(sys.stdout.encoding) # Make sure to double escape back slashes output = output.replace('\\', '\\\\\\') diff --git a/wa/framework/getters.py b/wa/framework/getters.py index 626bd031..9ca63bf7 100644 --- a/wa/framework/getters.py +++ b/wa/framework/getters.py @@ -244,10 +244,7 @@ class Http(ResourceGetter): response.status_code, response.reason)) return {} - if sys.version_info[0] == 3: - content = response.content.decode('utf-8') - else: - content = response.content + content = response.content.decode('utf-8') return json.loads(content) def download_asset(self, asset, owner_name): diff --git a/wa/framework/instrument.py b/wa/framework/instrument.py index 08da7025..73aa9b84 100644 --- a/wa/framework/instrument.py +++ b/wa/framework/instrument.py @@ -325,10 +325,7 @@ def install(instrument, context): if not callable(attr): msg = 'Attribute {} not callable in {}.' raise ValueError(msg.format(attr_name, instrument)) - if sys.version_info[0] == 3: - argspec = inspect.getfullargspec(attr) - else: - argspec = inspect.getargspec(attr) # pylint: disable=deprecated-method + argspec = inspect.getfullargspec(attr) arg_num = len(argspec.args) # Instrument callbacks will be passed exactly two arguments: self # (the instrument instance to which the callback is bound) and diff --git a/wa/framework/version.py b/wa/framework/version.py index 50f0ec2d..a329ce9c 100644 --- a/wa/framework/version.py +++ b/wa/framework/version.py @@ -57,7 +57,4 @@ def get_commit(): p.wait() if p.returncode: return None - if sys.version_info[0] == 3 and isinstance(std, bytes): - return std[:8].decode(sys.stdout.encoding or 'utf-8') - else: - return std[:8] + return std[:8].decode(sys.stdout.encoding or 'utf-8') diff --git a/wa/utils/misc.py b/wa/utils/misc.py index cc72bd05..88256fc8 100644 --- a/wa/utils/misc.py +++ b/wa/utils/misc.py @@ -41,10 +41,7 @@ from functools import reduce # pylint: disable=redefined-builtin from operator import mul from tempfile import gettempdir, NamedTemporaryFile from time import sleep -if sys.version_info[0] == 3: - from io import StringIO -else: - from io import BytesIO as StringIO +from io import StringIO # pylint: disable=wrong-import-position,unused-import from itertools import chain, cycle from distutils.spawn import find_executable # pylint: disable=no-name-in-module, import-error diff --git a/wa/utils/types.py b/wa/utils/types.py index 5d7b60a5..1e4f91ea 100644 --- a/wa/utils/types.py +++ b/wa/utils/types.py @@ -31,12 +31,8 @@ import numbers import shlex import sys from bisect import insort -if sys.version_info[0] == 3: - from urllib.parse import quote, unquote # pylint: disable=no-name-in-module, import-error - from past.builtins import basestring # pylint: disable=redefined-builtin - long = int # pylint: disable=redefined-builtin -else: - from urllib import quote, unquote # pylint: disable=no-name-in-module +from urllib.parse import quote, unquote # pylint: disable=no-name-in-module, import-error +from past.builtins import basestring # pylint: disable=redefined-builtin # pylint: disable=wrong-import-position from collections import defaultdict from collections.abc import MutableMapping @@ -710,8 +706,6 @@ class ParameterDict(dict): prefix = 'f' elif isinstance(obj, bool): prefix = 'b' - elif isinstance(obj, long): - prefix = 'i' elif isinstance(obj, int): prefix = 'i' elif obj is None: @@ -792,10 +786,7 @@ class ParameterDict(dict): return (key, self._decode(value)) def iter_encoded_items(self): - if sys.version_info[0] == 3: - return dict.items(self) - else: - return dict.iteritems(self) + return dict.items(self) def get_encoded_value(self, name): return dict.__getitem__(self, name) diff --git a/wa/workloads/jankbench/__init__.py b/wa/workloads/jankbench/__init__.py index 9b20bf1d..4817fced 100644 --- a/wa/workloads/jankbench/__init__.py +++ b/wa/workloads/jankbench/__init__.py @@ -223,8 +223,7 @@ class JankbenchRunMonitor(threading.Thread): ready, _, _ = select.select([proc.stdout, proc.stderr], [], [], 2) if ready: line = ready[0].readline() - if sys.version_info[0] == 3: - line = line.decode(sys.stdout.encoding, 'replace') + line = line.decode(sys.stdout.encoding, 'replace') if self.regex.search(line): self.run_ended.set() proc.terminate() diff --git a/wa/workloads/meabo/__init__.py b/wa/workloads/meabo/__init__.py index 899fcfe3..faef07d4 100644 --- a/wa/workloads/meabo/__init__.py +++ b/wa/workloads/meabo/__init__.py @@ -256,10 +256,7 @@ class Meabo(Workload): outfile = os.path.join(context.output_directory, 'meabo-output.txt') with open(outfile, 'wb') as wfh: - if sys.version_info[0] == 3: - wfh.write(self.output.encode('utf-8')) - else: - wfh.write(self.output) + wfh.write(self.output.encode('utf-8')) context.add_artifact('meabo-output', outfile, kind='raw') cur_phase = 0 diff --git a/wa/workloads/pcmark/__init__.py b/wa/workloads/pcmark/__init__.py index d2f22793..a7020c41 100755 --- a/wa/workloads/pcmark/__init__.py +++ b/wa/workloads/pcmark/__init__.py @@ -89,8 +89,7 @@ class PcMark(ApkUiautoWorkload): def update_output(self, context): expected_results = len(self.regex_matches[self.major_version]) zf = zipfile.ZipFile(os.path.join(context.output_directory, self.result_file), 'r').read('Result.xml') - if sys.version_info[0] == 3: - zf = zf.decode(sys.stdout.encoding) + zf = zf.decode(sys.stdout.encoding) for line in zf.split('\n'): for regex in self.regex_matches[self.major_version]: match = regex.search(line)