Skip to content

Commit be0f0d4

Browse files
committed
Prevent StopIteration from propagating out of the __len__ RecordSet method with empty results
1 parent dfccaba commit be0f0d4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pynetbox/core/response.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ def __len__(self):
8787
try:
8888
return self.request.count
8989
except AttributeError:
90-
self._response_cache.append(next(self.response))
90+
try:
91+
self._response_cache.append(next(self.response))
92+
except StopIteration:
93+
return 0
9194
return self.request.count
9295

9396

0 commit comments

Comments
 (0)