Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix "end" option
Fix line 190 to 193.
The print function corrected the end option not applied.
Added code performed when "end" value of parameter "kwargs" is not "nil".
  • Loading branch information
Sungmin-Joo committed Sep 25, 2019
commit e0de2bd7ba7517dce939bab0889a6762101efa46
12 changes: 8 additions & 4 deletions builtin/builtin.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,17 +176,21 @@ flush: whether to forcibly flush the stream.`

func builtin_print(self py.Object, args py.Tuple, kwargs py.StringDict) (py.Object, error) {
var (
sepObj py.Object = py.String(" ")
sepObj py.Object = py.String(" ")
Comment thread
corona10 marked this conversation as resolved.
Outdated
endObj py.Object = py.String("\n")
file py.Object = py.MustGetModule("sys").Globals["stdout"]
flush py.Object
flush py.Object
Comment thread
corona10 marked this conversation as resolved.
Outdated
)
kwlist := []string{"sep", "end", "file", "flush"}
err := py.ParseTupleAndKeywords(nil, kwargs, "|ssOO:print", kwlist, &sepObj, &endObj, &file, &flush)
if err != nil {
return nil, err
}
sep := sepObj.(py.String)

if kwargs["end"] != nil {
endObj = kwargs["end"]
}
end := endObj.(py.String)

write, err := py.GetAttrString(file, "write")
Expand All @@ -195,7 +199,7 @@ func builtin_print(self py.Object, args py.Tuple, kwargs py.StringDict) (py.Obje
}

for i, v := range args {
v, err := py.Str(v)
v, err := py.Str(v)
Comment thread
corona10 marked this conversation as resolved.
Outdated
if err != nil {
return nil, err
}
Expand All @@ -209,7 +213,7 @@ func builtin_print(self py.Object, args py.Tuple, kwargs py.StringDict) (py.Obje
_, err = py.Call(write, py.Tuple{sep}, nil)
if err != nil {
return nil, err
}
}
Comment thread
corona10 marked this conversation as resolved.
Outdated
}
}

Expand Down