File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -89,6 +89,19 @@ func PyByteArray_AsString(self *PyObject) string {
89
89
return C .GoString (c_str )
90
90
}
91
91
92
+ // Return the contents of bytearray as []bytes
93
+ func PyByteArray_AsBytes (self * PyObject ) []byte {
94
+ length := C ._gopy_PyByteArray_GET_SIZE (topy (self ))
95
+ c_str := C .PyByteArray_AsString (topy (self ))
96
+ return C .GoBytes (unsafe .Pointer (c_str ),C .int (length ))
97
+ }
98
+
99
+ // Return the contents of bytearray as []bytes, size length
100
+ func PyByteArray_AsBytesN (self * PyObject , length int ) []byte {
101
+ c_str := C .PyByteArray_AsString (topy (self ))
102
+ return C .GoBytes (unsafe .Pointer (c_str ),C .int (length ))
103
+ }
104
+
92
105
// int PyByteArray_Resize(PyObject *bytearray, Py_ssize_t len)
93
106
// Resize the internal buffer of bytearray to len.
94
107
func PyByteArray_Resize (self * PyObject , sz int ) error {
You can’t perform that action at this time.
0 commit comments