Skip to content

Commit f27c511

Browse files
committed
fix isSubClass: remove eager test which prevented checking for implementation of __subclasscheck__
- add abstract numbers issubclass tests
1 parent ca22d7c commit f27c511

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

graalpython/com.oracle.graal.python.test/src/tests/test_issubclass.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,13 @@ def test_subclass_tuple():
164164

165165
assert issubclass(int, (int, (float, int)))
166166
assert issubclass(str, (str, (Child, str)))
167+
168+
169+
def test_abstract_numbers_issubclass():
170+
from numbers import Number, Integral, Complex, Real
171+
assert issubclass(int, Number)
172+
assert issubclass(int, Integral)
173+
assert issubclass(int, Complex)
174+
175+
assert not issubclass(complex, Real)
176+
assert issubclass(complex, Complex)

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ public boolean isSubclass(Object derived, PTuple clsTuple,
759759

760760
@Fallback
761761
public boolean isSubclass(Object derived, Object cls) {
762-
return derived == cls || isInstanceCheckInternal(derived, cls) || isSubtypeNode.execute(derived, cls);
762+
return isInstanceCheckInternal(derived, cls) || isSubtypeNode.execute(derived, cls);
763763
}
764764
}
765765

0 commit comments

Comments
 (0)