Content-Length: 297451 | pFad | https://github.com/go-python/gpython/commit/f993dc7bd271e84110a5aaa73d1ec62b59540268

74 Make nil items return as None · go-python/gpython@f993dc7 · GitHub
Skip to content

Commit f993dc7

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

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

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)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/go-python/gpython/commit/f993dc7bd271e84110a5aaa73d1ec62b59540268

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy