Skip to content

Commit a54f823

Browse files
committed
fix system() func
1 parent 31318c4 commit a54f823

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

os/os.module.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,13 +244,15 @@ func system(self py.Object, args py.Tuple) (py.Object, error) {
244244
return nil, py.ExceptionNewf(py.TypeError, "missing one required argument: 'command:str'")
245245
}
246246
arg, ok := args[0].(py.String)
247-
if !ok { ... }
247+
if !ok {
248+
return nil, py.ExceptionNewf(py.TypeError, "str expected (pos 1), not "+args[0].Type().Name)
249+
}
248250

249251
var command *exec.Cmd
250252
if runtime.GOOS != "windows" {
251-
command = exec.Command("/bin/sh", "-c", carg)
253+
command = exec.Command("/bin/sh", "-c", string(arg))
252254
} else {
253-
command = exec.Command(cargs[0], cargs[1:]...)
255+
command = exec.Command("cmd.exe", string(arg))
254256
}
255257
outb, err := command.CombinedOutput() // - commbinedoutput to get both stderr and stdout -
256258
if err != nil {

0 commit comments

Comments
 (0)