changeset f9fb64a72259 in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=f9fb64a72259
description:
        config: ruby: Get rid of an "eval" and an "exec" operating on generated 
code.

        We can get the same result using importlib.

diffstat:

 configs/ruby/Ruby.py |  13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diffs (33 lines):

diff -r 6317351a288c -r f9fb64a72259 configs/ruby/Ruby.py
--- a/configs/ruby/Ruby.py      Fri Nov 21 17:22:19 2014 -0800
+++ b/configs/ruby/Ruby.py      Sun Nov 23 05:55:26 2014 -0800
@@ -39,6 +39,7 @@
 #
 # Authors: Brad Beckmann
 
+import importlib
 import math
 import m5
 from m5.objects import *
@@ -182,15 +183,15 @@
             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
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to