Skip to content

Commit 02e054d

Browse files
committed
Use getHashSize and asString in foreign.__bool__
1 parent c3e47ae commit 02e054d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignObjectBuiltins.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,12 @@ static boolean bool(Object receiver,
157157
if (lib.hasArrayElements(receiver)) {
158158
return lib.getArraySize(receiver) != 0;
159159
}
160+
if (lib.hasHashEntries(receiver)) {
161+
return lib.getHashSize(receiver) != 0;
162+
}
163+
if (lib.isString(receiver)) {
164+
return !lib.asString(receiver).isEmpty();
165+
}
160166
return !lib.isNull(receiver);
161167
} catch (UnsupportedMessageException e) {
162168
throw CompilerDirectives.shouldNotReachHere(e);

0 commit comments

Comments
 (0)