From ea0e3e8338c70c45532edcb7dccfccb9123981c4 Mon Sep 17 00:00:00 2001 From: Victor Skvortsov Date: Tue, 19 Oct 2021 18:34:19 +0500 Subject: [PATCH] Fix #2938 --- RELEASE.md | 3 +++ pelican/settings.py | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 RELEASE.md diff --git a/RELEASE.md b/RELEASE.md new file mode 100644 index 00000000..2291cffd --- /dev/null +++ b/RELEASE.md @@ -0,0 +1,3 @@ +Release type: patch + +Fix incorrect parsing of boolean parameters specified via `-e` / `--extra-settings` option flags (#2938). diff --git a/pelican/settings.py b/pelican/settings.py index ea3ee8eb..9edf838f 100644 --- a/pelican/settings.py +++ b/pelican/settings.py @@ -662,16 +662,21 @@ def configure_settings(settings): def coerce_overrides(overrides): + """Converts string values in the `overrides` dictionary + to correspoding Python types. + """ if overrides is None: return {} coerced = {} - types_to_cast = {int, str, bool} + types_to_cast = {int, str} for k, v in overrides.items(): if k not in DEFAULT_CONFIG: logger.warning('Override for unknown setting %s, ignoring', k) continue setting_type = type(DEFAULT_CONFIG[k]) - if setting_type not in types_to_cast: + if setting_type is bool: + coerced[k] = v not in {'', '0', 'false', 'False'} + elif setting_type not in types_to_cast: coerced[k] = json.loads(v) else: try: