1# mode: run 2 3cimport cython 4 5@cython.final 6cdef class TypedContextManager(object): 7 cdef double __enter__(self): # not callable from Python ! 8 return 2.0 9 # FIXME: inline __exit__() as well 10 def __exit__(self, exc_type, exc_value, exc_tb): 11 return 0 12 13def with_statement(): 14 """ 15 >>> with_statement() 16 2.0 17 """ 18 with TypedContextManager() as x: 19 return x 20