None returned in _load_atom_entries
SDK 1.3.1 client.py
when totalResults = 0, a empty array should be returned.. but
# Load an array of atom entries from the body of the given response
def _load_atom_entries(response):
r = _load_atom(response)
if 'feed' in r:
# Need this to handle a random case in the REST API
if r.feed.get('totalResults') == 0: <<-- it's actually a string "0" instead of number 0
return []
entries = r.feed.get('entry', None)
if entries is None: return None
return entries if isinstance(entries, list) else [entries]
# Unlike most other endpoints, the jobs endpoint does not return
# its state wrapped in another element, but at the top level.
# For example, in XML, it returns <entry>...</entry> instead of
# <feed><entry>...</entry></feed>.
else:
entries = r.get('entry', None)
if entries is None: return None
return entries if isinstance(entries, list) else [entries]
And in some cases, r.feed.get('totalResults') returns a None.
Thanks for the bug report! I've sent you both an email, we're busy getting ready for .Conf next week but we can look at fixing this after .Conf.
I'm thinking the following change seems reasonable (of course we'll need some tests):
- if r.feed.get('totalResults') == 0:
+ if r.feed.get('totalResults') in [0, '0', None]:
Hi folks,
I've made the following change with 27554e5796228c64c6a5d0f8dd859b3535f242c9 in develop. If the None case is still an issue, we'll address it in a future release.
- if r.feed.get('totalResults') == 0:
+ if r.feed.get('totalResults') in [0, '0']:
We've just released v1.5.0 which should address the '0' case.