In cython-devel there's now (experimental) support for a "nonecheck"
directive. It emulates the Python AttributeError on typed cdef class
variables set to None:
=====
"""
>>> getattr_(None)
Traceback (most recent call last):
...
AttributeError: 'NoneType' object has no attribute 'a'
"""
cimport cython
cdef class MyClass:
cdef int a
...
@cython.nonecheck(True)
def getattr_(MyClass var):
print var.a
=====
It will create inefficient code, inserting a check on any and all
attribute accesses. Haven't tested performance, any benchmarks welcome.
--
Dag Sverre
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev