From 64ed2fcc50144f65e54eb0949573c27560d9b64c Mon Sep 17 00:00:00 2001 From: Per Kraulis Date: Thu, 4 Nov 2021 14:23:27 +0100 Subject: [PATCH] Added argument checks for iterator. --- couchdb2.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/couchdb2.py b/couchdb2.py index 57ecb80..b940a50 100644 --- a/couchdb2.py +++ b/couchdb2.py @@ -6,7 +6,7 @@ and `tqdm`: https://tqdm.github.io/ """ -__version__ = "1.12.0" +__version__ = "1.12.1" # Standard packages import argparse @@ -1011,9 +1011,13 @@ class _DatabaseIterator(object): "Iterator over all documents, or all document identifiers, in a database." def __init__(self, db, limit=CHUNK_SIZE, include_docs=True): + if not isinstance(limit, int): + raise ValueError("'limit' is not an 'int'") + if limit <= 0: + raise ValueError("'limit' must be positive") self.db = db self.params = {"include_docs": bool(include_docs), - "limit": int(limit), + "limit": limit, "skip": 0} self.chunk = []