Commit 2c7a26ac authored by feilengcui008's avatar feilengcui008 Committed by Dylan Trotter

fix #30 and add #19 sys.stdin, sys.stdout, sys.stderr (#32)

parent 4033cdd9
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
"""System-specific parameters and functions.""" """System-specific parameters and functions."""
from __go__.os import Args from __go__.os import Args, Stdin, Stdout, Stderr
from __go__.grumpy import SysModules, MaxInt # pylint: disable=g-multiple-import from __go__.grumpy import SysModules, MaxInt, NewFileFromFD # pylint: disable=g-multiple-import
from __go__.runtime import Version from __go__.runtime import Version
argv = [] argv = []
...@@ -28,6 +28,10 @@ modules = SysModules ...@@ -28,6 +28,10 @@ modules = SysModules
py3kwarning = False py3kwarning = False
warnoptions = [] warnoptions = []
stdin = NewFileFromFD(Stdin.Fd())
stdout = NewFileFromFD(Stdout.Fd())
stderr = NewFileFromFD(Stderr.Fd())
class _Flags(object): class _Flags(object):
"""Container class for sys.flags.""" """Container class for sys.flags."""
......
...@@ -44,7 +44,9 @@ type File struct { ...@@ -44,7 +44,9 @@ type File struct {
// NewFileFromFD creates a file object from the given file descriptor fd. // NewFileFromFD creates a file object from the given file descriptor fd.
func NewFileFromFD(fd uintptr) *File { func NewFileFromFD(fd uintptr) *File {
// TODO: Use fcntl or something to get the mode of the descriptor. // TODO: Use fcntl or something to get the mode of the descriptor.
return &File{Object: Object{typ: FileType}, mode: "?", open: true, file: os.NewFile(fd, "<fdopen>")} file := &File{Object: Object{typ: FileType}, mode: "?", open: true, file: os.NewFile(fd, "<fdopen>")}
file.reader = bufio.NewReader(file.file)
return file
} }
func toFileUnsafe(o *Object) *File { func toFileUnsafe(o *Object) *File {
......
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