Skip to content

Commit

Permalink
Merge pull request #129 from digitalocean/fix-127
Browse files Browse the repository at this point in the history
Fixes IndexError when field is empty list.
  • Loading branch information
Zach Moody authored Dec 8, 2018
2 parents 8d5d981 + a33ccd3 commit 6e6a802
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@

v4.0.4 (2018-12-07)

## Bug Fixes
* Fixes IndexError introduced by fix for #127 when field is empty list.

---
v4.0.3 (2018-12-07)

## Bug Fixes
Expand Down
4 changes: 2 additions & 2 deletions pynetbox/core/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ def __iter__(self):
cur_attr = getattr(self, i)
if isinstance(cur_attr, Record):
yield i, dict(cur_attr)
elif isinstance(cur_attr, list) and isinstance(
cur_attr[0], Record
elif isinstance(cur_attr, list) and all(
isinstance(i, Record) for i in cur_attr
):
yield i, [dict(x) for x in cur_attr]
else:
Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def test_dict(self):
321,
231,
],
'empty_list': [],
'record_list': [
{
'id': 123,
Expand Down

0 comments on commit 6e6a802

Please sign in to comment.