Skip to content

Commit 51e0b46

Browse files
author
Sylvain Muller
authored
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.
1 parent eb06aee commit 51e0b46

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

interp/interp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ type Panic struct {
208208
}
209209

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

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

interp/run.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ func runCfg(n *node, f *frame) {
180180
if oNode == nil {
181181
oNode = n
182182
}
183-
fmt.Println(oNode.cfgErrorf("panic"))
183+
fmt.Fprintln(n.interp.stderr, oNode.cfgErrorf("panic"))
184184
f.mutex.Unlock()
185185
panic(f.recovered)
186186
}

0 commit comments

Comments
 (0)