Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions lume/parsers/numbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@ def isbool(x):


def try_int(x):
if x == int(x):
return int(x)
else:
return x
# int() raises on non-finite floats (inf/nan) and can overflow; such values
# (which appear in real Fortran/Astra/Impact numeric output) are left as-is.
try:
if x == int(x):
return int(x)
except (ValueError, OverflowError):
pass
return x


def try_bool(x):
Expand Down
Loading