From c855adc6e6008d3a2e5e132d1adcea17b14c2790 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Honza=20Kr=C3=A1l?= Date: Tue, 16 Aug 2016 20:46:04 +0200 Subject: [PATCH] None for parameter value should cause that param to be ignored Fixes #375 --- Changelog.rst | 2 ++ elasticsearch/client/utils.py | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Changelog.rst b/Changelog.rst index 952df062..183d5eb4 100644 --- a/Changelog.rst +++ b/Changelog.rst @@ -9,6 +9,8 @@ Changelog Version compatible with elasticsearch 5.0 * added ``headers`` arg to connections to support custom http headers + * passing in a keyword parameter with ``None`` as value will cause that param + to be ignored 2.3.0 (2016-02-29) ------------------ diff --git a/elasticsearch/client/utils.py b/elasticsearch/client/utils.py index 7a015a6b..2327d823 100644 --- a/elasticsearch/client/utils.py +++ b/elasticsearch/client/utils.py @@ -33,7 +33,7 @@ def _escape(value): except UnicodeDecodeError: # Python 2 and str, no need to re-encode pass - + return str(value) def _make_path(*parts): @@ -60,7 +60,9 @@ def query_params(*es_query_params): params = kwargs.pop('params', {}) for p in es_query_params + GLOBAL_PARAMS: if p in kwargs: - params[p] = _escape(kwargs.pop(p)) + v = kwargs.pop(p) + if v is not None: + params[p] = _escape(v) # don't treat ignore and request_timeout as other params to avoid escaping for p in ('ignore', 'request_timeout'):