@@ -1489,7 +1489,7 @@ def visit_Assert(self, node):
1489
1489
tail = self .current_block = self .add_block ()
1490
1490
self .append (ir .BranchIf (cond , tail , if_failed ), block = head )
1491
1491
1492
- def polymorphic_print (self , values , separator , suffix = "" ):
1492
+ def polymorphic_print (self , values , separator , suffix = "" , as_repr = False ):
1493
1493
format_string = ""
1494
1494
args = []
1495
1495
def flush ():
@@ -1508,7 +1508,7 @@ def flush():
1508
1508
format_string += "(" ; flush ()
1509
1509
self .polymorphic_print ([self .append (ir .GetAttr (value , index ))
1510
1510
for index in range (len (value .type .elts ))],
1511
- separator = ", " )
1511
+ separator = ", " , as_repr = True )
1512
1512
if len (value .type .elts ) == 1 :
1513
1513
format_string += ",)"
1514
1514
else :
@@ -1538,7 +1538,10 @@ def flush():
1538
1538
format_string += "%g"
1539
1539
args .append (value )
1540
1540
elif builtins .is_str (value .type ):
1541
- format_string += "%s"
1541
+ if as_repr :
1542
+ format_string += "\" %s\" "
1543
+ else :
1544
+ format_string += "%s"
1542
1545
args .append (value )
1543
1546
elif builtins .is_list (value .type ):
1544
1547
format_string += "[" ; flush ()
@@ -1547,7 +1550,7 @@ def flush():
1547
1550
last = self .append (ir .Arith (ast .Sub (loc = None ), length , ir .Constant (1 , length .type )))
1548
1551
def body_gen (index ):
1549
1552
elt = self .iterable_get (value , index )
1550
- self .polymorphic_print ([elt ], separator = "" )
1553
+ self .polymorphic_print ([elt ], separator = "" , as_repr = True )
1551
1554
is_last = self .append (ir .Compare (ast .Lt (loc = None ), index , last ))
1552
1555
head = self .current_block
1553
1556
0 commit comments