Skip to content

Commit

Permalink
Fix for segmentation fault if unexpected data-type is given to locali…
Browse files Browse the repository at this point in the history
…ze_decimal() helper (mainly protects from integer 0 from summation of empty lists)
  • Loading branch information
titov-vv committed Apr 1, 2024
1 parent 600aba3 commit f544fb9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions jal/db/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ def remove_exponent(d) -> Decimal:
def localize_decimal(value: Decimal, precision: int = None, percent: bool = False, sign: bool = False) -> str:
if value is None:
return ''
if type(value) != Decimal:
try:
value = Decimal(value)
except:
return f"* {value} *" # Indicate failure
if value.is_nan():
return Setup.NULL_VALUE
if percent:
Expand Down

0 comments on commit f544fb9

Please sign in to comment.