Use fmt.Fprintln instead of fmt.Println in runCfg

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.
This commit is contained in:
Sylvain Muller
2021-02-20 12:08:03 +01:00
committed by GitHub
parent eb06aeeb26
commit 51e0b46256
2 changed files with 2 additions and 2 deletions

View File

@@ -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) }

View File

@@ -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)
}