Merge pull request #11355 from mvdbeek/fix_non_fatal_log_exceptions_in_cheetah_handling

[21.01] Don't log handled exceptions when filling cheetah template
This commit is contained in:
Marius van den Beek
2021-02-12 12:28:04 +01:00
committed by GitHub
2 changed files with 5 additions and 4 deletions
+4 -3
View File
@@ -1015,7 +1015,7 @@ def roundify(amount, sfs=2):
return amount[0:sfs] + '0' * (len(amount) - sfs)
def unicodify(value, encoding=DEFAULT_ENCODING, error='replace', strip_null=False):
def unicodify(value, encoding=DEFAULT_ENCODING, error='replace', strip_null=False, log_exception=True):
"""
Returns a Unicode string or None.
@@ -1041,8 +1041,9 @@ def unicodify(value, encoding=DEFAULT_ENCODING, error='replace', strip_null=Fals
if not isinstance(value, str):
value = str(value, encoding, error)
except Exception as e:
msg = "Value '{}' could not be coerced to Unicode: {}('{}')".format(repr(value), type(e).__name__, e)
log.exception(msg)
if log_exception:
msg = "Value '{}' could not be coerced to Unicode: {}('{}')".format(repr(value), type(e).__name__, e)
log.exception(msg)
raise
if strip_null:
return value.replace('\0', '')
+1 -1
View File
@@ -77,7 +77,7 @@ def fill_template(template_text,
raise first_exception or e
t = klass(searchList=[context])
try:
return unicodify(t)
return unicodify(t, log_exception=False)
except NotFound as e:
if first_exception is None:
first_exception = e