Commit b5f04d53 authored by Dong-hee Na's avatar Dong-hee Na Committed by Dylan Trotter

Switch from os.Stderr to Stderr. (#249)

parent 39a7d60b
......@@ -17,7 +17,6 @@ package grumpy
import (
"fmt"
"log"
"os"
"reflect"
)
......@@ -756,7 +755,7 @@ func StartThread(callable *Object) {
if raised != nil {
s = raised.String()
}
fmt.Fprintf(os.Stderr, s)
Stderr.writeString(s)
}
}()
}
......
......@@ -289,7 +289,7 @@ func RunMain(code *Code) int {
m.state = moduleStateInitializing
f := NewRootFrame()
if raised := SysModules.SetItemString(f, "__main__", m.ToObject()); raised != nil {
fmt.Fprint(os.Stderr, raised.String())
Stderr.writeString(raised.String())
}
_, e := code.Eval(f, m.Dict(), nil, nil)
if e == nil {
......@@ -300,7 +300,7 @@ func RunMain(code *Code) int {
if raised != nil {
s = e.String()
}
fmt.Fprint(os.Stderr, s)
Stderr.writeString(s)
return 1
}
f.RestoreExc(nil, nil)
......@@ -315,7 +315,7 @@ func RunMain(code *Code) int {
return 0
}
if s, raised := ToStr(f, o); raised == nil {
fmt.Fprintln(os.Stderr, s.Value())
Stderr.writeString(s.Value() + "\n")
}
return 1
}
......@@ -307,15 +307,15 @@ func TestRunMain(t *testing.T) {
}
func runMainAndCaptureStderr(code *Code) (int, string, error) {
oldStderr := os.Stderr
oldStderr := Stderr
defer func() {
os.Stderr = oldStderr
Stderr = oldStderr
}()
r, w, err := os.Pipe()
if err != nil {
return 0, "", err
}
os.Stderr = w
Stderr = NewFileFromFD(w.Fd())
c := make(chan int)
go func() {
defer w.Close()
......
......@@ -16,7 +16,6 @@ package grumpy
import (
"fmt"
"os"
"reflect"
"runtime"
"sync"
......@@ -194,7 +193,7 @@ func weakRefFinalizeReferent(o *Object) {
if raised != nil {
s = raised.String()
}
fmt.Fprint(os.Stderr, s)
Stderr.writeString(s)
}
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment