Пример #1
0
func stringify(obj Object) string {
	tpyS := C.PyObject_Str(c(obj))
	defer C.decref(tpyS)
	u := C.PyUnicode_AsUTF8String(tpyS)
	defer C.decref(u)
	return C.GoString(C.PyBytes_AsString(u))
}
Пример #2
0
func (u *Unicode) String() string {
	if u == nil {
		return "<nil>"
	}
	s := C.PyUnicode_AsUTF8String(c(u))
	if s == nil {
		panic(exception())
	}
	defer C.decref(s)
	ret := C.PyString_AsString(s)
	if ret == nil {
		panic(exception())
	}
	return C.GoString(ret)
}
Пример #3
0
func (u *Unicode) UTF8String() (Object, error) {
	ret := C.PyUnicode_AsUTF8String(c(u))
	return obj2ObjErr(ret)
}