summaryrefslogtreecommitdiff
path: root/configs/common/SysPaths.py
diff options
context:
space:
mode:
authorAndreas Sandberg <andreas.sandberg@arm.com>2019-01-26 10:57:44 +0000
committerAndreas Sandberg <andreas.sandberg@arm.com>2019-02-26 10:28:00 +0000
commit32bbddf2362421021b016d995f5e27b2bceea3a2 (patch)
tree500971374192fb73f41ee41a4e419a61bfca03b9 /configs/common/SysPaths.py
parentc38a6523ab4df2b57337be0b2446bd9d30be94b4 (diff)
downloadgem5-32bbddf2362421021b016d995f5e27b2bceea3a2.tar.xz
configs: Fix Python 3 iterator and exec compatibility issues
Python 2.7 used to return lists for operations such as map and range, this has changed in Python 3. To make the configs Python 3 compliant, add explicit conversions from iterators to lists where needed, replace xrange with range, and fix changes to exec syntax. This change doesn't fix import paths since that might require us to restructure the configs slightly. Change-Id: Idcea8482b286779fc98b4e144ca8f54069c08024 Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-on: https://gem5-review.googlesource.com/c/16002 Reviewed-by: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'configs/common/SysPaths.py')
-rw-r--r--configs/common/SysPaths.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/configs/common/SysPaths.py b/configs/common/SysPaths.py
index 9a234ccec..17d5fb864 100644
--- a/configs/common/SysPaths.py
+++ b/configs/common/SysPaths.py
@@ -26,6 +26,8 @@
#
# Authors: Ali Saidi
+
+from six import string_types
import os, sys
config_path = os.path.dirname(os.path.abspath(__file__))
@@ -35,7 +37,7 @@ class PathSearchFunc(object):
_sys_paths = None
def __init__(self, subdirs, sys_paths=None):
- if isinstance(subdirs, basestring):
+ if isinstance(subdirs, string_types):
subdirs = [subdirs]
self._subdir = os.path.join(*subdirs)
if sys_paths:
@@ -55,16 +57,16 @@ class PathSearchFunc(object):
paths = filter(os.path.isdir, paths)
if not paths:
- raise IOError, "Can't find a path to system files."
+ raise IOError("Can't find a path to system files.")
- self._sys_paths = paths
+ self._sys_paths = list(paths)
filepath = os.path.join(self._subdir, filename)
paths = (os.path.join(p, filepath) for p in self._sys_paths)
try:
return next(p for p in paths if os.path.exists(p))
except StopIteration:
- raise IOError, "Can't find file '%s' on path." % filename
+ raise IOError("Can't find file '%s' on path." % filename)
disk = PathSearchFunc('disks')
binary = PathSearchFunc('binaries')