Commit c2c1a2ad authored by Stefan Behnel's avatar Stefan Behnel

added test for cdef attribute access on type checked variable

parent 6853d59e
......@@ -2,7 +2,9 @@
#cython: autotestdict=True
cdef class Foo:
pass
cdef int i
def __cinit__(self):
self.i = 1
cdef class SubFoo(Foo):
pass
......@@ -55,6 +57,25 @@ def foo3(arg):
"""
cdef val = <Foo?>arg
def attribute_access(arg):
"""
>>> attribute_access(Foo())
>>> attribute_access(SubFoo())
>>> attribute_access(None)
Traceback (most recent call last):
...
TypeError: Cannot convert NoneType to typetest_T417.Foo
>>> attribute_access(123)
Traceback (most recent call last):
...
TypeError: Cannot convert int to typetest_T417.Foo
>>> attribute_access(Bar())
Traceback (most recent call last):
...
TypeError: Cannot convert typetest_T417.Bar to typetest_T417.Foo
"""
cdef val = (<Foo?>arg).i
cdef int count = 0
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment