Skip to content

Commit

Permalink
Use fmt.Fprintln instead of fmt.Println in runCfg
Browse files Browse the repository at this point in the history
As mentioned in #1030, when an Eval panic, it is print with `fmt.Println()` and not to the configured `interp.Options.Stderr`. According to https://github.com/traefik/yaegi/blob/master/interp/interp.go#L210, it should be removed in future version so I'm not sure if this pull request is necessary. However, it could fix the issue in the meanwhile.

Fixes #1030.
  • Loading branch information
Sylvain Muller authored Feb 20, 2021
1 parent eb06aee commit 51e0b46
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion interp/interp.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ type Panic struct {
}

// TODO: Capture interpreter stack frames also and remove
// fmt.Println(n.cfgErrorf("panic")) in runCfg.
// fmt.Fprintln(n.interp.stderr, oNode.cfgErrorf("panic")) in runCfg.

func (e Panic) Error() string { return fmt.Sprint(e.Value) }

Expand Down
2 changes: 1 addition & 1 deletion interp/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func runCfg(n *node, f *frame) {
if oNode == nil {
oNode = n
}
fmt.Println(oNode.cfgErrorf("panic"))
fmt.Fprintln(n.interp.stderr, oNode.cfgErrorf("panic"))
f.mutex.Unlock()
panic(f.recovered)
}
Expand Down

0 comments on commit 51e0b46

Please sign in to comment.