From: Andreas Sandberg Date: Fri, 25 Jan 2019 18:38:03 +0000 (+0000) Subject: python: Add Python 3 workarounds for long X-Git-Tag: v19.0.0.0~1100 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b5b19d247024022a93df320158a2aea2a772e54f;p=gem5.git python: Add Python 3 workarounds for long Python 3 doesn't have a separate long type. Make long an alias for int where needed to maintain compatibility. Change-Id: I4c0861302bc3a2fa5226b3041803ef975d29b2fd Signed-off-by: Andreas Sandberg Reviewed-on: https://gem5-review.googlesource.com/c/15988 Reviewed-by: Nikos Nikoleris --- diff --git a/src/python/m5/SimObject.py b/src/python/m5/SimObject.py index 5a869125e..7f19c0776 100644 --- a/src/python/m5/SimObject.py +++ b/src/python/m5/SimObject.py @@ -45,6 +45,9 @@ from __future__ import print_function from __future__ import absolute_import +import six +if six.PY3: + long = int import sys from types import FunctionType, MethodType, ModuleType diff --git a/src/python/m5/params.py b/src/python/m5/params.py index 757a4f238..ff625e0d6 100644 --- a/src/python/m5/params.py +++ b/src/python/m5/params.py @@ -60,6 +60,9 @@ ##################################################################### from __future__ import print_function +import six +if six.PY3: + long = int import copy import datetime diff --git a/src/python/m5/proxy.py b/src/python/m5/proxy.py index b939bc059..5128156df 100644 --- a/src/python/m5/proxy.py +++ b/src/python/m5/proxy.py @@ -47,6 +47,9 @@ from __future__ import print_function from __future__ import absolute_import +import six +if six.PY3: + long = int import copy diff --git a/src/python/m5/ticks.py b/src/python/m5/ticks.py index 22a5738d3..7a740a84a 100644 --- a/src/python/m5/ticks.py +++ b/src/python/m5/ticks.py @@ -27,6 +27,9 @@ # Authors: Nathan Binkert from __future__ import print_function +import six +if six.PY3: + long = int import sys from m5.util import warn diff --git a/src/python/m5/util/convert.py b/src/python/m5/util/convert.py index acd1a2448..76ac509dc 100644 --- a/src/python/m5/util/convert.py +++ b/src/python/m5/util/convert.py @@ -28,6 +28,10 @@ # Authors: Nathan Binkert # Gabe Black +import six +if six.PY3: + long = int + # metric prefixes atto = 1.0e-18 femto = 1.0e-15 diff --git a/src/python/m5/util/fdthelper.py b/src/python/m5/util/fdthelper.py index bd04b4154..c8760508c 100644 --- a/src/python/m5/util/fdthelper.py +++ b/src/python/m5/util/fdthelper.py @@ -35,6 +35,10 @@ # # Author: Glenn Bergmans +import six +if six.PY3: + long = int + from m5.ext.pyfdt import pyfdt import re import os diff --git a/src/python/m5/util/smartdict.py b/src/python/m5/util/smartdict.py index 3cfe3294e..dabc3f86b 100644 --- a/src/python/m5/util/smartdict.py +++ b/src/python/m5/util/smartdict.py @@ -43,6 +43,9 @@ from __future__ import print_function from __future__ import absolute_import +import six +if six.PY3: + long = int from .convert import * from .attrdict import attrdict