File tree Expand file tree Collapse file tree 3 files changed +8
-2
lines changed
Expand file tree Collapse file tree 3 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -105,6 +105,10 @@ final PyString float___repr__() {
105105 }
106106
107107 private String formatDouble (int precision ) {
108+ if (Double .isNaN (value )) {
109+ return "nan" ;
110+ }
111+
108112 String result = String .format ("%%.%dg" , precision );
109113 result = Py .newString (result ).__mod__ (this ).toString ();
110114
Original file line number Diff line number Diff line change @@ -1510,6 +1510,10 @@ public double atof() {
15101510 try {
15111511 // Double.valueOf allows format specifier ("d" or "f") at the end
15121512 String lowSval = sval .toLowerCase ();
1513+ if (lowSval .equals ("nan" )) return Double .NaN ;
1514+ else if (lowSval .equals ("inf" )) return Double .POSITIVE_INFINITY ;
1515+ else if (lowSval .equals ("-inf" )) return Double .NEGATIVE_INFINITY ;
1516+
15131517 if (lowSval .endsWith ("d" ) || lowSval .endsWith ("f" )) {
15141518 throw new NumberFormatException ("format specifiers not allowed" );
15151519 }
Original file line number Diff line number Diff line change @@ -351,8 +351,6 @@ BigInteger get_ulong(PyObject value) {
351351 }
352352
353353 double get_float (PyObject value ) {
354- if (!(value instanceof PyFloat ))
355- throw StructError ("required argument is not an float" );
356354 return value .__float__ ().getValue ();
357355 }
358356
You can’t perform that action at this time.
0 commit comments