go-python / go-python/gopy

[]byte Parameter Results in Unexpected Integer Type

Open
#344 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
Go
Stars
2.3k
Forks
136
Avg merge
14m
Merged PRs (30d)
2

Description

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.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the provided test.go and test.py reproduction, then inspect the generated wrapper for Test and the conversion of the MengByte parameter. Run the example to confirm the Python callback receives an integer. Done means the []byte-based MengByte value is exposed to Python as a bytes object rather than an integer.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, python
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.