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

Lines changed: 4 additions & 1 deletion
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

Lines changed: 10 additions & 5 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy