Blame tests/run/inlined_context_manager.pyx
|
Packit |
562c7a |
# mode: run
|
|
Packit |
562c7a |
|
|
Packit |
562c7a |
cimport cython
|
|
Packit |
562c7a |
|
|
Packit |
562c7a |
@cython.final
|
|
Packit |
562c7a |
cdef class TypedContextManager(object):
|
|
Packit |
562c7a |
cdef double __enter__(self): # not callable from Python !
|
|
Packit |
562c7a |
return 2.0
|
|
Packit |
562c7a |
# FIXME: inline __exit__() as well
|
|
Packit |
562c7a |
def __exit__(self, exc_type, exc_value, exc_tb):
|
|
Packit |
562c7a |
return 0
|
|
Packit |
562c7a |
|
|
Packit |
562c7a |
def with_statement():
|
|
Packit |
562c7a |
"""
|
|
Packit |
562c7a |
>>> with_statement()
|
|
Packit |
562c7a |
2.0
|
|
Packit |
562c7a |
"""
|
|
Packit |
562c7a |
with TypedContextManager() as x:
|
|
Packit |
562c7a |
return x
|