python: Remove Python 2.7 compatibility code
We don't support Python 2.7 anymore. Remove glue code like the six dependency and "from __future__" imports from gem5's standard library. Change-Id: I71834c325f86ff0329b222be87794ead96081f05 Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/39584 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Gabe Black <gabe.black@gmail.com> Maintainer: Jason Lowe-Power <power.jg@gmail.com>
This commit is contained in:
@@ -37,14 +37,11 @@
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
from six import string_types
|
||||
from six.moves import zip_longest
|
||||
from itertools import zip_longest
|
||||
|
||||
from . import convert
|
||||
from . import jobfile
|
||||
@@ -123,7 +120,7 @@ def compareVersions(v1, v2):
|
||||
def make_version_list(v):
|
||||
if isinstance(v, (list,tuple)):
|
||||
return v
|
||||
elif isinstance(v, string_types):
|
||||
elif isinstance(v, str):
|
||||
return list(map(lambda x: int(re.match('\d+', x).group()),
|
||||
v.split('.')))
|
||||
else:
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
__all__ = [ 'attrdict', 'multiattrdict', 'optiondict' ]
|
||||
|
||||
class attrdict(dict):
|
||||
|
||||
@@ -24,9 +24,6 @@
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
from __future__ import print_function
|
||||
from six import add_metaclass
|
||||
|
||||
try:
|
||||
import builtins
|
||||
except ImportError:
|
||||
@@ -112,8 +109,7 @@ class code_formatter_meta(type):
|
||||
}
|
||||
cls.pattern = re.compile(pat, re.VERBOSE | re.DOTALL | re.MULTILINE)
|
||||
|
||||
@add_metaclass(code_formatter_meta)
|
||||
class code_formatter(object):
|
||||
class code_formatter(object, metaclass=code_formatter_meta):
|
||||
delim = r'$'
|
||||
ident = r'[_A-z]\w*'
|
||||
pos = r'[0-9]+'
|
||||
|
||||
@@ -25,10 +25,6 @@
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import six
|
||||
if six.PY3:
|
||||
long = int
|
||||
|
||||
# metric prefixes
|
||||
atto = 1.0e-18
|
||||
femto = 1.0e-15
|
||||
|
||||
@@ -53,9 +53,6 @@
|
||||
#
|
||||
#####################################################################
|
||||
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
|
||||
import m5, os, re
|
||||
from m5.SimObject import isRoot, isSimObjectVector
|
||||
from m5.params import PortRef, isNullPointer
|
||||
|
||||
@@ -35,10 +35,6 @@
|
||||
#
|
||||
# Author: Glenn Bergmans
|
||||
|
||||
import six
|
||||
if six.PY3:
|
||||
long = int
|
||||
|
||||
from m5.ext.pyfdt import pyfdt
|
||||
import re
|
||||
import os
|
||||
@@ -56,7 +52,7 @@ class FdtPropertyWords(pyfdt.FdtPropertyWords):
|
||||
words = [words]
|
||||
# Make sure all values are ints (use automatic base detection if the
|
||||
# type is str)
|
||||
words = [long(w, base=0) if type(w) == str else long(w) for w in words]
|
||||
words = [int(w, base=0) if type(w) == str else int(w) for w in words]
|
||||
super(FdtPropertyWords, self).__init__(name, words)
|
||||
|
||||
class FdtPropertyStrings(pyfdt.FdtPropertyStrings):
|
||||
@@ -122,7 +118,7 @@ class FdtState(object):
|
||||
def int_to_cells(self, value, cells):
|
||||
"""Helper function for: generates a list of 32 bit cells from an int,
|
||||
used to split up addresses in appropriate 32 bit chunks."""
|
||||
value = long(value)
|
||||
value = int(value)
|
||||
|
||||
if (value >> (32 * cells)) != 0:
|
||||
fatal("Value %d doesn't fit in %d cells" % (value, cells))
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import os
|
||||
from six import string_types
|
||||
|
||||
import ply.lex
|
||||
import ply.yacc
|
||||
@@ -94,7 +93,7 @@ class Grammar(object):
|
||||
"'%s' object has no attribute '%s'" % (type(self), attr))
|
||||
|
||||
def parse_string(self, data, source='<string>', debug=None, tracking=0):
|
||||
if not isinstance(data, string_types):
|
||||
if not isinstance(data, str):
|
||||
raise AttributeError(
|
||||
"argument must be a string, was '%s'" % type(f))
|
||||
|
||||
@@ -113,7 +112,7 @@ class Grammar(object):
|
||||
return result
|
||||
|
||||
def parse_file(self, f, **kwargs):
|
||||
if isinstance(f, string_types):
|
||||
if isinstance(f, str):
|
||||
source = f
|
||||
f = open(f, 'r')
|
||||
elif isinstance(f, file):
|
||||
|
||||
@@ -24,9 +24,6 @@
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
|
||||
import sys
|
||||
|
||||
class Data(object):
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
__all__ = [ 'multidict' ]
|
||||
|
||||
class multidict(object):
|
||||
|
||||
@@ -33,14 +33,9 @@
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
from six import add_metaclass
|
||||
|
||||
from abc import *
|
||||
|
||||
@add_metaclass(ABCMeta)
|
||||
class PyBindExport(object):
|
||||
class PyBindExport(object, metaclass=ABCMeta):
|
||||
@abstractmethod
|
||||
def export(self, code, cname):
|
||||
pass
|
||||
|
||||
@@ -26,9 +26,6 @@
|
||||
#
|
||||
# Author: Steve Reinhardt
|
||||
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
|
||||
import sys
|
||||
|
||||
# Intended usage example:
|
||||
|
||||
Reference in New Issue
Block a user