From 0fb50c5a575d2f9993cf10934c7ceadeffdeefc2 Mon Sep 17 00:00:00 2001 From: Tiara Rodney Date: Fri, 15 Apr 2022 02:28:02 +0200 Subject: [PATCH] fix(helper/config::typecast): add boolean evaluation --- src/httpaste/helper/config.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/httpaste/helper/config.py b/src/httpaste/helper/config.py index f053cf3..29795e3 100755 --- a/src/httpaste/helper/config.py +++ b/src/httpaste/helper/config.py @@ -3,6 +3,7 @@ from pathlib import Path from configparser import ConfigParser, NoSectionError from typing import Optional, NamedTuple from os import environ +from ast import literal_eval CONFIGPATH_ENVIRON = 'HTTPASTE_CONFIGPATH' @@ -49,8 +50,9 @@ def typecast(obj: dict, aclass: type, dirname:Optional[Path] = None) -> dict: casted[k] = casted_val = dirname / v elif issubclass(bclass, bytes): - casted[k] = bclass(v.encode('utf-8')) + elif issubclass(bclass, bool): + casted[k] = literal_eval(v) else: try: casted_val = bclass(v)