blob packing exception
- Dominant language
- Python
- Stars
- 114
- Forks
- 26
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
client send_message raise exception when sending blobs
**To Reproduce**
OSCClient(b'localhost', 10000).send_message(b'/my_uuid', [bytearray(range(16)),])
**Expected behavior**
16 bytes blob sent to server
**Logs/output**
Traceback (most recent call last):
File "", line 1, in
File "C:\Utils\Python3\lib\site-packages\oscpy\client.py", line 136, in send_message
stats = send_message(
File "C:\Utils\Python3\lib\site-packages\oscpy\client.py", line 63, in send_message
message, stats = format_message(
File "C:\Utils\Python3\lib\site-packages\oscpy\parser.py", line 271, in format_message
message = pack(
struct.error: pack expected 26 items for packing (got 3)
**Platform (please complete the following information):**
- OS: windows 10
- Python 3.7
- release
**Additional context**
**_THE REASON_**
WRITERS = (
...
(bytearray, (b'b', b'%ib')),
mean
struct.pack(b'16b', bytearray(range(16))) # it is not valid
struct.error: pack expected 16 items for packing (got 1)
**_FIX_**
it shoulfd be:
struct.pack(b'16s', bytearray(range(16)))
so,
WRITERS = (
...
(bytearray, (b's', b'%ib')),
Contributor guide
Research direction
Start with client.py:136 and parser.py:271, following send_message into format_message and the WRITERS entry for bytearray. Reproduce the issue with the OSCClient example from the report, then verify that sending a 16-byte bytearray no longer raises struct.error and is received by the server as a 16-byte blob.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100