Skip to content

all: remove use of deprecated io/ioutil package #173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compile/compile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ package compile

import (
"fmt"
"io/ioutil"
"io"
"os/exec"
"testing"

Expand Down Expand Up @@ -118,7 +118,7 @@ func EqCodeCode(t *testing.T, name string, a, b string) {
t.Errorf("%s code want %q, got %q", name, a, b)
return
}
stdoutData, err := ioutil.ReadAll(stdout)
stdoutData, err := io.ReadAll(stdout)
if err != nil {
t.Fatalf("Failed to read data: %v", err)
}
Expand Down
3 changes: 1 addition & 2 deletions modules/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package modules

import (
"bytes"
"io/ioutil"
"os"
"path"
"path/filepath"
Expand Down Expand Up @@ -145,7 +144,7 @@ func (ctx *context) ResolveAndCompile(pathname string, opts py.CompileOpts) (py.
switch ext {
case ".py":
var pySrc []byte
pySrc, err = ioutil.ReadFile(fpath)
pySrc, err = os.ReadFile(fpath)
if err != nil {
return false, py.ExceptionNewf(py.OSError, "Error reading %q: %v", fpath, err)
}
Expand Down
4 changes: 2 additions & 2 deletions parser/testparser/testparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package main
import (
"flag"
"fmt"
"io/ioutil"
"io"
"log"
"os"

Expand Down Expand Up @@ -47,7 +47,7 @@ func main() {
_, err = parser.Lex(in, path, "exec")
} else if *compileFile {
var input []byte
input, err = ioutil.ReadAll(in)
input, err = io.ReadAll(in)
if err != nil {
log.Fatalf("Failed to read %q: %v", path, err)
}
Expand Down
3 changes: 1 addition & 2 deletions py/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ package py

import (
"io"
"io/ioutil"
"os"
)

Expand Down Expand Up @@ -129,7 +128,7 @@ func (o *File) Read(args Tuple, kwargs StringDict) (Object, error) {
return nil, ExceptionNewf(TypeError, "read() argument 1 must be int, not %s", arg.Type().Name)
}

b, err := ioutil.ReadAll(r)
b, err := io.ReadAll(r)
if err != nil {
if err == io.EOF {
return o.readResult(nil)
Expand Down
6 changes: 3 additions & 3 deletions pytest/pytest.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
package pytest

import (
"io/ioutil"
"io"
"os"
"path"
"strings"
Expand All @@ -31,7 +31,7 @@ func compileProgram(t testing.TB, prog string) (*py.Module, *py.Code) {
}
}()

str, err := ioutil.ReadAll(f)
str, err := io.ReadAll(f)
if err != nil {
t.Fatalf("%s: ReadAll failed: %v", prog, err)
}
Expand Down Expand Up @@ -92,7 +92,7 @@ func run(t testing.TB, module *py.Module, code *py.Code) {

// find the python files in the directory passed in
func findFiles(t testing.TB, testDir string) (names []string) {
files, err := ioutil.ReadDir(testDir)
files, err := os.ReadDir(testDir)
if err != nil {
t.Fatalf("ReadDir failed: %v", err)
}
Expand Down