Python: Fix a conditional expression that requires Python 2.5
authorAndreas Hansson <andreas.hansson@arm.com>
Wed, 21 Mar 2012 23:02:03 +0000 (19:02 -0400)
committerAndreas Hansson <andreas.hansson@arm.com>
Wed, 21 Mar 2012 23:02:03 +0000 (19:02 -0400)
This patch changes a conditional expression to a conventional if/else
block, which does not require Python >= 2.5.

src/python/m5/SimObject.py

index a447d96db7c1f1c492909f70049283c83783ccf1..8c14be28730acc8cd22c0b6cbf5b6312c5bb1cba 100644 (file)
@@ -993,8 +993,12 @@ class SimObject(object):
         port_names.sort()
         for port_name in port_names:
             port = self._port_refs.get(port_name, None)
+            if port != None:
+                port_count = len(port)
+            else:
+                port_count = 0
             setattr(cc_params, 'port_' + port_name + '_connection_count',
-                    len(port) if port != None else 0)
+                    port_count)
         self._ccParams = cc_params
         return self._ccParams