File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed
graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -1029,8 +1029,8 @@ private double convertStringToDoubleOrThrow(String str) throws NumberFormatExcep
1029
1029
1030
1030
for (int i = 0 ; i < n ; i ++) {
1031
1031
char ch = str .charAt (i );
1032
- if (ch == '\u0000' ) {
1033
- throw raise ( ValueError , ErrorMessages . EMPTY_STR_FOR_COMPLEX );
1032
+ if (ch == '\u0000' || ch == 'x' || ch == 'X' ) {
1033
+ throw new NumberFormatException ( );
1034
1034
}
1035
1035
if (Character .isDigit (ch )) {
1036
1036
if (s == null ) {
@@ -1039,11 +1039,14 @@ private double convertStringToDoubleOrThrow(String str) throws NumberFormatExcep
1039
1039
int val = Character .digit (ch , 10 );
1040
1040
s .setCharAt (i , Character .forDigit (val , 10 ));
1041
1041
}
1042
+ if (Character .isWhitespace (ch )) {
1043
+ if (s == null ) {
1044
+ s = new StringBuilder (str );
1045
+ }
1046
+ s .setCharAt (i , ' ' );
1047
+ }
1042
1048
}
1043
- String sval = str .trim ();
1044
- if (s != null ) {
1045
- sval = s .toString ();
1046
- }
1049
+ String sval = s != null ? s .toString () : str .trim ();
1047
1050
String lowSval = sval .toLowerCase (Locale .ENGLISH );
1048
1051
if (lowSval .equals ("nan" ) || lowSval .equals ("+nan" )) {
1049
1052
return Double .NaN ;
You can’t perform that action at this time.
0 commit comments