Skip to content

DynamoDB's Binary type issues with Python 3 #846

@miguelgrinberg

Description

@miguelgrinberg

The Binary class has a problematic implementation of the __str__() method that assumes str and bytes are interchangeable. Example:

Python 3.5.2 (default, Sep 28 2016, 18:11:34)
>>> from boto3.dynamodb.types import Binary
>>> b = Binary(b'hello')

>>> b
Binary(b'hello')

>>> print(b)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: __str__ returned non-string (type bytes)

>>> bytes(b)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'Binary' object is not iterable

The above examples all succeed under Python 2.7.

Metadata

Metadata

Assignees

No one assigned

    Labels

    dynamodbfeature-requestThis issue requests a feature.p3This is a minor priority issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions