From da0c1c64dec3f70ca751b1b1335ebb8baca6c3d1 Mon Sep 17 00:00:00 2001 From: David A Ham Date: Tue, 26 Aug 2014 14:02:44 +0100 Subject: [PATCH] Correctly stringify tuple subscripts. Python turns multiple subscripts separated by commas into a tuple of subscripts. When stringifying this, Pymbolic inserts the set of parentheses associated with that tuple inside the square brackets for the subscript. This commit causes Pymbolic to suppress these parentheses. --- pymbolic/mapper/stringifier.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pymbolic/mapper/stringifier.py b/pymbolic/mapper/stringifier.py index c379c04..65c991a 100644 --- a/pymbolic/mapper/stringifier.py +++ b/pymbolic/mapper/stringifier.py @@ -138,6 +138,8 @@ class StringifyMapper(pymbolic.mapper.Mapper): return self.parenthesize_if_needed( self.format("%s[%s]", self.rec(expr.aggregate, PREC_CALL), + self.join_rec(", ", expr.index, PREC_NONE) if + isinstance(expr.index, tuple) else self.rec(expr.index, PREC_NONE)), enclosing_prec, PREC_CALL) -- GitLab