go-python / go-python/gopy

[]byte Parameter Results in Unexpected Integer Type

未关闭
#344 1 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Go
星标
2.3k
派生
136
平均合并
14 分钟
30 天内合并 PR
2

描述

I am facing an issue with Golang-to-Python interoperability. Specifically, when I call a Python function from Golang and pass a []byte data as a parameter, the Python function unexpectedly receives an integer instead of the intended MengByte/bytes object.

Code:

test.go
```go
package hujan

type MengByte []byte
type Fungsi func(MengByte)

func Test(fun Fungsi) {
fun(MengByte{255, 211, 21, 23, 0, 1, 2, 3, 82, 2, 33})
}
```

test.py
```python
from out.hujan import Test, MengByte

def fun(arg: MengByte):
print('arg: ', type(arg))
return arg

Test(fun)
```

I would appreciate assistance in resolving this issue and ensuring that the Python function correctly receives the MengByte/bytes object.

贡献指南

这个仓库没有索引到贡献指南

调研方向

从提供的 test.go 和 test.py 复现开始,然后检查为 Test 生成的 wrapper 以及 MengByte 参数的转换。运行示例,确认 Python 回调接收到的是整数。当基于 []byte 的 MengByte 值以 bytes 对象而不是整数的形式暴露给 Python 时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
go, python
领域
backend
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。