summaryrefslogtreecommitdiff
path: root/tests/run/pytype.pyx
blob: 7911d6c7d8fbe50b11d14a9a5d8d40deee08640f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from cpython.type cimport PyType_IsSubtype

class mylist(list): pass

def test_issubtype(a, b):
    """
    >>> test_issubtype(mylist, list)
    True
    >>> test_issubtype(mylist, dict)
    False

    >>> o = object()
    >>> test_issubtype(o, list)
    Traceback (most recent call last):
    ...
    TypeError: Cannot convert object to type
    """
    return PyType_IsSubtype(a, b)