diff options
author | Gabe Black <gabeblack@google.com> | 2014-11-23 05:55:26 -0800 |
---|---|---|
committer | Gabe Black <gabeblack@google.com> | 2014-11-23 05:55:26 -0800 |
commit | 12243a3835272255940389ea3a749a34613f6d96 (patch) | |
tree | ae546ce36302c8ddc6a537ee9024f7f592297977 /configs | |
parent | 2d2a5aa410eb99d79367ae66125514b3975c4618 (diff) | |
download | gem5-12243a3835272255940389ea3a749a34613f6d96.tar.xz |
config: ruby: Get rid of an "eval" and an "exec" operating on generated code.
We can get the same result using importlib.
Diffstat (limited to 'configs')
-rw-r--r-- | configs/ruby/Ruby.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/configs/ruby/Ruby.py b/configs/ruby/Ruby.py index 44d6bdfcc..98df027dc 100644 --- a/configs/ruby/Ruby.py +++ b/configs/ruby/Ruby.py @@ -39,6 +39,7 @@ # # Authors: Brad Beckmann +import importlib import math import m5 from m5.objects import * @@ -182,15 +183,15 @@ def create_system(options, full_system, system, piobus = None, dma_ports = []): routers = [], ext_links = [], int_links = [], netifs = []) ruby.network = network - protocol = buildEnv['PROTOCOL'] - exec "import %s" % protocol + protocol_name = buildEnv['PROTOCOL'] + protocol = importlib.import_module(protocol_name) try: (cpu_sequencers, dir_cntrls, topology) = \ - eval("%s.create_system(options, full_system, system, dma_ports,\ - ruby)" - % protocol) + protocol.create_system(options, full_system, system, dma_ports, + ruby) except: - print "Error: could not create sytem for ruby protocol %s" % protocol + print "Error: could not create sytem for ruby protocol %s" % \ + protocol_name raise # Create a port proxy for connecting the system port. This is |