Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions _examples/gobytes/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,12 @@
assert empty_bytes == b"", "expected b'', got %r" % (empty_bytes,)
print("Go empty bytes to Python: ", empty_bytes)

# Regression test for issue #359 (reverse direction): converting a 0-length
# Python bytes to a Go []byte, then back, must not crash either.
empty_from_bytes = go.Slice_byte.from_bytes(b"")
print("Python empty bytes to Go: ", empty_from_bytes)
roundtrip_bytes = bytes(empty_from_bytes)
assert roundtrip_bytes == b"", "expected b'', got %r" % (roundtrip_bytes,)
print("Go empty bytes round-trip: ", roundtrip_bytes)

print("OK")
2 changes: 2 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ Python bytes to Go: go.Slice_byte len: 4 handle: 3 [0, 1, 2, 3]
Go bytes to Python: b'\x03\x04\x05'
Go empty slice: go.Slice_byte len: 0 handle: 5 []
Go empty bytes to Python: b''
Python empty bytes to Go: go.Slice_byte len: 0 handle: 6 []
Go empty bytes round-trip: b''
OK
`),
})
Expand Down
Loading