Switched from __nonzero__ to __bool__ when checking for falsiness. The former was deprecated in python 3.0.

This commit is contained in:
Eric Traut 2019-09-15 11:11:17 -07:00
parent 18300ba5b6
commit a83c46d229

View File

@ -460,7 +460,7 @@ export function canBeTruthy(type: Type): boolean {
} }
// None is always falsy. All other types are generally truthy // None is always falsy. All other types are generally truthy
// unless they are objects that support the __nonzero__ or __len__ // unless they are objects that support the __bool__ or __len__
// methods. // methods.
export function canBeFalsy(type: Type): boolean { export function canBeFalsy(type: Type): boolean {
if (type.category === TypeCategory.None) { if (type.category === TypeCategory.None) {
@ -481,8 +481,8 @@ export function canBeFalsy(type: Type): boolean {
return true; return true;
} }
const nonZeroMethod = lookUpObjectMember(type, '__nonzero__'); const boolethod = lookUpObjectMember(type, '__bool__');
if (nonZeroMethod) { if (boolethod) {
return true; return true;
} }
} }