Skip to content

Commit f993dc7

Browse files
committed
Make nil items return as None
1 parent 216cff9 commit f993dc7

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

ast/dump.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import (
99
)
1010

1111
func dumpItem(v interface{}) string {
12+
if v == nil {
13+
return "None"
14+
}
1215
switch x := v.(type) {
1316
case py.String:
1417
return fmt.Sprintf("'%s'", string(x))

ast/dump_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func TestDump(t *testing.T) {
2525
{&Name{Id: Identifier("hello"), Ctx: Load}, `Name(id='hello', ctx=Load())`},
2626
{&ListComp{Elt: &Str{S: py.String("potato")}, Generators: []Comprehension{{
2727
Target: &Name{Id: Identifier("hello"), Ctx: Load},
28-
}}}, `ListComp(elt=Str(s='potato'), generators=[comprehension(target=Name(id='hello', ctx=Load()), iter=<nil>, ifs=[])])`},
28+
}}}, `ListComp(elt=Str(s='potato'), generators=[comprehension(target=Name(id='hello', ctx=Load()), iter=None, ifs=[])])`},
2929
} {
3030
out := Dump(test.in)
3131
if out != test.out {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy