diff --git a/byte_array.go b/byte_array.go index a027f95..c52d2d6 100644 --- a/byte_array.go +++ b/byte_array.go @@ -52,7 +52,7 @@ func PyByteArray_Size(o *PyObject) int { //PyByteArray_AsString : https://docs.python.org/3/c-api/bytearray.html#c.PyByteArray_AsString func PyByteArray_AsString(o *PyObject) string { - return C.GoString(C.PyByteArray_AsString(toc(o))) + return C.GoStringN(C.PyByteArray_AsString(toc(o)), C.int(C.PyByteArray_Size(toc(o)))) } //PyByteArray_Resize : https://docs.python.org/3/c-api/bytearray.html#c.PyByteArray_Resize diff --git a/bytes.go b/bytes.go index 0e91377..1ed45d2 100644 --- a/bytes.go +++ b/bytes.go @@ -47,7 +47,7 @@ func PyBytes_Size(o *PyObject) int { //PyBytes_AsString : https://docs.python.org/3/c-api/bytes.html#c.PyBytes_AsString func PyBytes_AsString(o *PyObject) string { - return C.GoString(C.PyBytes_AsString(toc(o))) + return C.GoStringN(C.PyBytes_AsString(toc(o)), C.int(C.PyBytes_Size(toc(o)))) } //PyBytes_Concat : https://docs.python.org/3/c-api/bytes.html#c.PyBytes_Concat