From 4d7fc32a242c1a9d607467dab56d5ccc971554cf Mon Sep 17 00:00:00 2001 From: Ben Leslie Date: Tue, 16 Nov 2021 01:49:36 +0000 Subject: [PATCH] Remove python2 support for core build tools Depedencies on Python2/3 cross support (such as six, past and future) are removed as only Python3 is supported at this point. Fewer external deps is a good thing. Signed-off-by: Ben Leslie Signed-off-by: Ivan Velickovic --- tools/bitfield_gen.py | 2 -- tools/lex.py | 23 +++-------------------- tools/umm.py | 4 +--- 3 files changed, 4 insertions(+), 25 deletions(-) diff --git a/tools/bitfield_gen.py b/tools/bitfield_gen.py index 4f7406184..c3331749b 100755 --- a/tools/bitfield_gen.py +++ b/tools/bitfield_gen.py @@ -13,7 +13,6 @@ # See bitfield_gen.md for syntax, examples, and more information. ## -from __future__ import print_function, division import sys import os.path import optparse @@ -21,7 +20,6 @@ import re import itertools import tempfile -from six.moves import range from functools import reduce import lex diff --git a/tools/lex.py b/tools/lex.py index 4c9b15402..4ff9ac61d 100644 --- a/tools/lex.py +++ b/tools/lex.py @@ -36,35 +36,18 @@ __version__ = "3.2" __tabversion__ = "3.2" # Version of table file used -from past.builtins import cmp import re import sys import types import copy import os -# Python3 doesn't have a build-in cmp function. -# We need to import it here, even though it isn't called in this file -# when interpreted by python3, to prevent pylint from treating it as -# an error. +StringTypes = (str, bytes) -# This tuple contains known string types -try: - # Python 2.6 - StringTypes = (types.StringType, types.UnicodeType) -except AttributeError: - # Python 3.0 - StringTypes = (str, bytes) -# Extract the code attribute of a function. Different implementations -# are for Python 2/3 compatibility. +def func_code(f): + return f.__code__ -if sys.version_info[0] < 3: - def func_code(f): - return f.func_code -else: - def func_code(f): - return f.__code__ # This regular expression is used to match valid token names _is_identifier = re.compile(r'^[a-zA-Z0-9_]+$') diff --git a/tools/umm.py b/tools/umm.py index 92c41e3da..e4f8ff73d 100755 --- a/tools/umm.py +++ b/tools/umm.py @@ -5,9 +5,7 @@ # SPDX-License-Identifier: BSD-2-Clause # -from __future__ import print_function import sys -import six from functools import reduce # We assume length tp > 0 @@ -119,7 +117,7 @@ def print_graph(filename, out_file): mp = build_types(filename) print('digraph types {', file=out_file) - for k, flds in six.iteritems(mp): + for k, flds in mp.iteritems(): for fld, tp in flds: # if is_base(tp): print('\t "%s" -> "%s" [label="%s"]' % (k, base_name(tp), fld),