// PyByteArray_AsBytesN returns the contents of bytearray as []bytes, size length func PyByteArray_AsBytesN(self *PyObject, length int) []byte { blength := int(C._gopy_PyByteArray_GET_SIZE(topy(self))) if (blength < length) || (length < 0) { panic("bytearray length out of range") } c_str := C.PyByteArray_AsString(topy(self)) return C.GoBytes(unsafe.Pointer(c_str), C.int(length)) }
// Py_ssize_t PyByteArray_GET_SIZE(PyObject *bytearray) // Macro version of PyByteArray_Size(). func PyByteArray_GET_SIZE(self *PyObject) int { return int(C._gopy_PyByteArray_GET_SIZE(topy(self))) }
// PyByteArray_AsBytes returns the contents of bytearray as []bytes func PyByteArray_AsBytes(self *PyObject) []byte { length := C._gopy_PyByteArray_GET_SIZE(topy(self)) c_str := C.PyByteArray_AsString(topy(self)) return C.GoBytes(unsafe.Pointer(c_str), C.int(length)) }