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