Esempio n. 1
0
func AddToPath(dir string) {
	p := C.CString("path")
	defer C.free(unsafe.Pointer(p))

	sys_path := C.PySys_GetObject(p)
	if sys_path == nil {
		return
	}

	s := C.CString(dir)
	defer C.free(unsafe.Pointer(s))

	pDir := C.PyUnicode_FromString(s)
	if pDir == nil {
		return
	}

	C.PyList_Append(sys_path, pDir)
}
Esempio n. 2
0
// PyObject *PySys_GetObject(char *name)
// Return value: Borrowed reference.
// Return the object name from the sys module or NULL if it does not exist, without setting an exception.
func PySys_GetObject(name string) *PyObject {
	c_name := C.CString(name)
	defer C.free(unsafe.Pointer(c_name))

	return togo(C.PySys_GetObject(c_name))
}