Skip to content

Commit cc59dde

Browse files
committed
Fix uses of Compile
1 parent e1d9f2c commit cc59dde

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

builtin/builtin.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,10 @@ func builtin_compile(self py.Object, args py.Tuple, kwargs py.StringDict) py.Obj
544544
// } else {
545545
str := source_as_string(cmd, "compile", "string, bytes or AST" /*, &cf*/)
546546
// result = py.CompileStringExFlags(str, filename, start[mode], &cf, optimize)
547-
result = compile.Compile(str, string(filename.(py.String)), string(startstr.(py.String)), int(supplied_flags.(py.Int)), dont_inherit.(py.Int) != 0)
547+
result, err := compile.Compile(str, string(filename.(py.String)), string(startstr.(py.String)), int(supplied_flags.(py.Int)), dont_inherit.(py.Int) != 0)
548+
if err != nil {
549+
panic(err)
550+
}
548551
// }
549552

550553
return result

main.go

+10-5
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,20 @@ package main
55
import (
66
"flag"
77
"fmt"
8+
89
_ "github.com/ncw/gpython/builtin"
910
//_ "github.com/ncw/gpython/importlib"
11+
"io/ioutil"
12+
"log"
13+
"os"
14+
"strings"
15+
1016
"github.com/ncw/gpython/compile"
1117
"github.com/ncw/gpython/marshal"
1218
"github.com/ncw/gpython/py"
1319
_ "github.com/ncw/gpython/sys"
1420
_ "github.com/ncw/gpython/time"
1521
"github.com/ncw/gpython/vm"
16-
"io/ioutil"
17-
"log"
18-
"os"
19-
"strings"
2022
)
2123

2224
// Globals
@@ -73,7 +75,10 @@ func main() {
7375
if err != nil {
7476
log.Fatal(err)
7577
}
76-
obj = compile.Compile(string(str), prog, "exec", 0, true)
78+
obj, err = compile.Compile(string(str), prog, "exec", 0, true)
79+
if err != nil {
80+
log.Fatalf("Can't compile %q: %v", prog, err)
81+
}
7782
} else {
7883
log.Fatalf("Can't execute %q", prog)
7984
}

0 commit comments

Comments
 (0)