Use GoStringN inside _AsString functions for bytes as they may contain NULLs
parent
0b25cc5505
commit
0ae938000d
|
@ -52,7 +52,7 @@ func PyByteArray_Size(o *PyObject) int {
|
||||||
|
|
||||||
//PyByteArray_AsString : https://docs.python.org/3/c-api/bytearray.html#c.PyByteArray_AsString
|
//PyByteArray_AsString : https://docs.python.org/3/c-api/bytearray.html#c.PyByteArray_AsString
|
||||||
func PyByteArray_AsString(o *PyObject) string {
|
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
|
//PyByteArray_Resize : https://docs.python.org/3/c-api/bytearray.html#c.PyByteArray_Resize
|
||||||
|
|
2
bytes.go
2
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
|
//PyBytes_AsString : https://docs.python.org/3/c-api/bytes.html#c.PyBytes_AsString
|
||||||
func PyBytes_AsString(o *PyObject) string {
|
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
|
//PyBytes_Concat : https://docs.python.org/3/c-api/bytes.html#c.PyBytes_Concat
|
||||||
|
|
Loading…
Reference in New Issue