Skip to content

Commit ccb2ce3

Browse files
Kolpatimfel
authored andcommitted
fixed isUpper to behave more like the python equivalent
1 parent afa6ba2 commit ccb2ce3

File tree

1 file changed

+4
-4
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str

1 file changed

+4
-4
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/StringBuiltins.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1827,21 +1827,21 @@ abstract static class IsUpperNode extends PythonUnaryBuiltinNode {
18271827
@Specialization
18281828
@TruffleBoundary
18291829
boolean doString(String self) {
1830-
int spaces = 0;
1830+
int uncased = 0;
18311831
if (self.length() == 0) {
18321832
return false;
18331833
}
18341834
for (int i = 0; i < self.length(); i++) {
18351835
int codePoint = self.codePointAt(i);
18361836
if (!Character.isUpperCase(codePoint)) {
1837-
if (Character.isWhitespace(codePoint)) {
1838-
spaces++;
1837+
if (Character.toLowerCase(codePoint) == Character.toUpperCase(codePoint)) {
1838+
uncased++;
18391839
} else {
18401840
return false;
18411841
}
18421842
}
18431843
}
1844-
return spaces == 0 || self.length() > spaces;
1844+
return uncased == 0 || self.length() > uncased;
18451845

18461846
}
18471847
}

0 commit comments

Comments
 (0)