[3.4] Disallow NaN and Infinity in Trivia CONFIG schema (#5949) (#6083)

Co-authored-by: Jakub Kuczys <me@jacken.men>
This commit is contained in:
Red-GitHubBot
2023-04-20 02:58:15 +02:00
committed by GitHub
parent 5367246dc2
commit 69f757758d

View File

@@ -1,4 +1,5 @@
import itertools
import math
import re
from typing import Any, NoReturn
@@ -18,8 +19,8 @@ class SchemaErrorMessage(str):
def int_or_float(value: Any) -> float:
if not isinstance(value, (float, int)):
raise TypeError("Value needs to be an integer or a float.")
if not isinstance(value, (float, int)) or not math.isfinite(value):
raise TypeError("Value needs to be an integer or a finite float.")
return float(value)