DynamoDB's Binary type issues with Python 3
See original GitHub issueThe 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.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:13
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Unable to parse AWS DynamoDB binary get ... - Stack Overflow
class Binary: """A class for representing Binary in dynamodb Especially for Python 2, ... Unicode and Python 3 string types are not allowed....
Read more >Source code for boto3.dynamodb.types - AWS
It is essentially a wrapper around binary. Unicode and Python 3 string types are not allowed. """ def __init__(self, value): if not isinstance(value, ......
Read more >Error handling with DynamoDB - AWS Documentation
Discover the best practices for handling client and server errors and exceptions returned by Amazon DynamoDB operations.
Read more >The Three DynamoDB Limits You Need to Know - Alex DeBrie
In other cases, the limit may alter how you structure your solution, such as how the 15 minute limit on Lambda execution time...
Read more >Unable to parse AWS DynamoDB binary get item in boto3 ...
Unicode and Python 3 string types are not allowed. """ def __init__(self, value): if not isinstance(value, BINARY_TYPES): types = ', '.join([str(t) for t...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I encountered this issue also. Found I could work around it by accessing the value directly. E.g.
Why is this marked as
feature-request
? It’s a bug that happens in Python3.Also, why is the
Binary
wrapper class needed at all?