File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -89,15 +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
92
+ // PyByteArray_AsBytes returns the contents of bytearray as []bytes
93
93
func PyByteArray_AsBytes (self * PyObject ) []byte {
94
94
length := C ._gopy_PyByteArray_GET_SIZE (topy (self ))
95
95
c_str := C .PyByteArray_AsString (topy (self ))
96
96
return C .GoBytes (unsafe .Pointer (c_str ),C .int (length ))
97
97
}
98
98
99
- // Return the contents of bytearray as []bytes, size length
100
- func PyByteArray_AsBytesN (self * PyObject , length int ) []byte {
99
+ // PyByteArray_AsBytesN returns the contents of bytearray as []bytes, size length
100
+ func PyByteArray_AsBytesN (self * PyObject , length uint64 ) []byte {
101
+ blength := uint64 (C ._gopy_PyByteArray_GET_SIZE (topy (self )))
102
+ if blength < length {
103
+ panic ("bytearray length out of range" )
104
+ }
101
105
c_str := C .PyByteArray_AsString (topy (self ))
102
106
return C .GoBytes (unsafe .Pointer (c_str ),C .int (length ))
103
107
}
You can’t perform that action at this time.
0 commit comments