Skip to content

Commit dc76883

Browse files
committed
Fix String dump
1 parent 4ab8fc2 commit dc76883

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

ast/dump.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func Dump(ast Ast) string {
4343
v := fieldValue.Interface()
4444
switch x := v.(type) {
4545
case py.String:
46-
args = append(args, fmt.Sprintf("%s=%q", fname, string(x)))
46+
args = append(args, fmt.Sprintf("%s='%s'", fname, string(x)))
4747
case py.Bytes:
4848
args = append(args, fmt.Sprintf("%s=b'%s'", fname, string(x)))
4949
case Identifier:

ast/dump_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ func TestDump(t *testing.T) {
1313
}{
1414
{nil, `<nil>`},
1515
{&Pass{}, `Pass()`},
16-
{&Str{S: py.String("potato")}, `Str(s="potato")`},
17-
{&Str{S: py.String("potato")}, `Str(s="potato")`},
16+
{&Str{S: py.String("potato")}, `Str(s='potato')`},
17+
{&Str{S: py.String("potato")}, `Str(s='potato')`},
1818
{&Bytes{S: py.Bytes("potato")}, `Bytes(s=b'potato')`},
1919
{&BinOp{Left: &Str{S: py.String("one")}, Op: Add, Right: &Str{S: py.String("two")}},
20-
`BinOp(left=Str(s="one"), op=Add(), right=Str(s="two"))`},
20+
`BinOp(left=Str(s='one'), op=Add(), right=Str(s='two'))`},
2121
{&Module{}, `Module(body=[])`},
2222
{&Module{Body: []Stmt{&Pass{}}}, `Module(body=[Pass()])`},
2323
{&Module{Body: []Stmt{&ExprStmt{Value: &Tuple{}}}}, `Module(body=[Expr(value=Tuple(elts=[], ctx=UnknownExprContext(0)))])`},

0 commit comments

Comments
 (0)