From a9b28dff36e64ae0bbb4fa1f088b002fca4ccd3d Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Fri, 19 Dec 2014 14:40:20 +0800 Subject: [PATCH] transforms/lower_units: support empty list --- artiq/transforms/lower_units.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/artiq/transforms/lower_units.py b/artiq/transforms/lower_units.py index 7573c2d3d..f86f24a90 100644 --- a/artiq/transforms/lower_units.py +++ b/artiq/transforms/lower_units.py @@ -89,10 +89,11 @@ class _UnitsLowerer(ast.NodeTransformer): def visit_List(self, node): self.generic_visit(node) - us = [getattr(elt, "unit", None) for elt in node.elts] - if not all(u == us[0] for u in us[1:]): - raise units.DimensionError - node.unit = us[0] + if node.elts: + us = [getattr(elt, "unit", None) for elt in node.elts] + if not all(u == us[0] for u in us[1:]): + raise units.DimensionError + node.unit = us[0] return node def visit_ListComp(self, node):