Skip to content

Commit 75bee24

Browse files
committed
allowing None on converter to_integer
1 parent f4099b7 commit 75bee24

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

datamodel/converters.pyx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ cpdef object to_integer(object obj):
9494
9595
Returns object converted to integer.
9696
"""
97+
if obj is None:
98+
return None
9799
if isinstance(obj, int):
98100
return obj
99101
elif callable(obj):
@@ -107,7 +109,7 @@ cpdef object to_integer(object obj):
107109
return int(obj)
108110
except (TypeError, ValueError) as e:
109111
raise ValueError(
110-
f"Invalid conversion to Integer of literal {obj}"
112+
f"Invalid conversion to Integer of {obj}"
111113
) from e
112114

113115
cpdef object to_float(object obj):

0 commit comments

Comments
 (0)