Skip to content

Conversation

Inotart
Copy link
Contributor

@Inotart Inotart commented Apr 30, 2024

修复 python 3.12 版本无法编译的Bug
原生成后代码:

func Slice_byte_to_bytes(handle CGoHandle) *C.PyObject {
	s := deptrFromHandle_Slice_byte(handle)
	ptr := unsafe.Pointer(&s[0])
	size := len(s)
	return C.PyBytes_FromStringAndSize((*C.char)(ptr), C.long(size))
}

替换此例子中的C.long为C.longlong
实测修复后gopy build 正常

@rcoreilly
Copy link
Member

thanks for the fix -- makes sense!

@rcoreilly rcoreilly merged commit 277bbad into go-python:master May 3, 2024
@rcoreilly
Copy link
Member

actually, this gives all kinds of errors on python 3.11:

./hi.go:304:53: cannot use _Ctype_longlong(size) (value of type _Ctype_longlong) as _Ctype_long value in argument to (_Cfunc_PyBytes_FromStringAndSize)

so I guess this is a 3.12 vs 11 difference?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants