Skip to content

b'...' is not JSON serializable #1

@nathan-osman

Description

@nathan-osman

When passing a dict as an attachment to Connection.send(), there is no check whether the content value is a unicode or binary value. If a binary value is passed, the following exception is raised:

File "connection.py", line 80, in send
    'attachments': list(self._process_attachments(attachments)),
...
File "/usr/lib/python3.5/json/encoder.py", line 180, in default
    raise TypeError(repr(o) + " is not JSON serializable")
TypeError: b'...' is not JSON serializable

The correct behavior would be for Connection._process_attachments() to detect this, encode the value with base64, and set encoded to True in the JSON payload to Hectane.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions