File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,9 @@ def format(
4848 if abs (number ) < cutoff :
4949 number = Decimal ("0" )
5050
51+ if not number .is_finite ():
52+ return str (number )
53+
5154 # Format values with more than 200 digits (an arbitrary cutoff) using
5255 # scientific notation to avoid high memory usage in {:f}'.format().
5356 _ , digits , exponent = number .as_tuple ()
Original file line number Diff line number Diff line change @@ -153,6 +153,9 @@ def test_intcomma(self):
153153 "-1234567.1234567" ,
154154 Decimal ("1234567.1234567" ),
155155 Decimal ("-1234567.1234567" ),
156+ Decimal ("Infinity" ),
157+ Decimal ("-Infinity" ),
158+ Decimal ("NaN" ),
156159 None ,
157160 "1234567" ,
158161 "-1234567" ,
@@ -193,6 +196,9 @@ def test_intcomma(self):
193196 "-1,234,567.1234567" ,
194197 "1,234,567.1234567" ,
195198 "-1,234,567.1234567" ,
199+ "Infinity" ,
200+ "-Infinity" ,
201+ "NaN" ,
196202 None ,
197203 "1,234,567" ,
198204 "-1,234,567" ,
You can’t perform that action at this time.
0 commit comments