Skip to content

Commit

Permalink
Merge pull request boto#3459 from Newstex/develop
Browse files Browse the repository at this point in the history
Fixed to make previous commit python3 safe
  • Loading branch information
kyleknap committed Jan 12, 2016
2 parents c3c1ddd + efbb906 commit 6627d77
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion boto/dynamodb/types.py
Original file line number Diff line number Diff line change
@@ -333,7 +333,7 @@ def decode(self, attr):
the appropriate python type.
"""
if len(attr) > 1 or not attr or isinstance(attr, basestring):
if len(attr) > 1 or not attr or is_str(attr):
return attr
dynamodb_type = list(attr.keys())[0]
if dynamodb_type.lower() == dynamodb_type:
9 changes: 8 additions & 1 deletion tests/unit/dynamodb/test_types.py
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@
from decimal import Decimal
from tests.compat import unittest

from boto.compat import six
from boto.compat import six, json
from boto.dynamodb import types
from boto.dynamodb.exceptions import DynamoDBNumberError

@@ -95,6 +95,13 @@ def test_lossy_float_conversions(self):
self.assertEqual(dynamizer.decode({'NS': ['1.1', '2.2', '3.3']}),
set([1.1, 2.2, 3.3]))

def test_decoding_full_doc(self):
'''Simple List decoding that had caused some errors'''
dynamizer = types.Dynamizer()
doc = '{"__type__":{"S":"Story"},"company_tickers":{"SS":["NASDAQ-TSLA","NYSE-F","NYSE-GM"]},"modified_at":{"N":"1452525162"},"created_at":{"N":"1452525162"},"version":{"N":"1"},"categories":{"SS":["AUTOMTVE","LTRTR","MANUFCTU","PN","PRHYPE","TAXE","TJ","TL"]},"provider_categories":{"L":[{"S":"F"},{"S":"GM"},{"S":"TSLA"}]},"received_at":{"S":"2016-01-11T11:26:31Z"}}'
output_doc = {'provider_categories': ['F', 'GM', 'TSLA'], '__type__': 'Story', 'company_tickers': set(['NASDAQ-TSLA', 'NYSE-GM', 'NYSE-F']), 'modified_at': Decimal('1452525162'), 'version': Decimal('1'), 'received_at': '2016-01-11T11:26:31Z', 'created_at': Decimal('1452525162'), 'categories': set(['LTRTR', 'TAXE', 'MANUFCTU', 'TL', 'TJ', 'AUTOMTVE', 'PRHYPE', 'PN'])}
self.assertEqual(json.loads(doc, object_hook=dynamizer.decode), output_doc)


class TestBinary(unittest.TestCase):
def test_good_input(self):

0 comments on commit 6627d77

Please sign in to comment.