8000 Implement PySys_SetArgv. · hdfsun/go-python@a80f13c · GitHub
[go: up one dir, main page]

Skip to content

Commit a80f13c

Browse files
tfogalsbinet
authored andcommitted
Implement PySys_SetArgv.
Not that the interface is slightly different: we don't take an argument count, since we can just grab the length of the array.
1 parent 9486a27 commit a80f13c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

utilities.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,4 +489,15 @@ func PyEval_GetFuncDesc(fct *PyObject) string {
489489
return C.GoString(c_name)
490490
}
491491

492+
// PySys_SetArgv initializes the 'sys.argv' array in python.
493+
func PySys_SetArgv(argv []string) {
494+
argc := C.int(len(argv))
495+
cargs := make([]*C.char, len(argv))
496+
for idx, arg := range argv {
497+
cargs[idx] = C.CString(arg)
498+
defer C.free(unsafe.Pointer(cargs[idx]))
499+
}
500+
C.PySys_SetArgv(argc, &cargs[0])
501+
}
502+
492503
// EOF

0 commit comments

Comments
 (0)
0