summaryrefslogtreecommitdiff
path: root/docs/examples/tutorial/string
diff options
context:
space:
mode:
authorgabrieldemarmiesse <gabriel.demarmiesse@teraki.com>2018-06-18 21:25:01 +0200
committergabrieldemarmiesse <gabriel.demarmiesse@teraki.com>2018-06-18 21:25:01 +0200
commit943547222486155b20634ab10acf2d9dc5da99af (patch)
treecbaeb5a5e11c1ff1eef99c1fe9b1608b44c0514c /docs/examples/tutorial/string
parent5c04c1a8ffd3a09c00cad41604bb648b786b8dda (diff)
downloadcython-943547222486155b20634ab10acf2d9dc5da99af.tar.gz
Moved an example from string.rst to the examples directory.
Diffstat (limited to 'docs/examples/tutorial/string')
-rw-r--r--docs/examples/tutorial/string/try_finally.pyx9
1 files changed, 9 insertions, 0 deletions
diff --git a/docs/examples/tutorial/string/try_finally.pyx b/docs/examples/tutorial/string/try_finally.pyx
new file mode 100644
index 000000000..aea786f5b
--- /dev/null
+++ b/docs/examples/tutorial/string/try_finally.pyx
@@ -0,0 +1,9 @@
+from libc.stdlib cimport free
+from c_func cimport c_call_returning_a_c_string
+
+cdef bytes py_string
+cdef char* c_string = c_call_returning_a_c_string()
+try:
+ py_string = c_string
+finally:
+ free(c_string)