diff options
Diffstat (limited to 'docs/examples/tutorial/string/try_finally.pyx')
-rw-r--r-- | docs/examples/tutorial/string/try_finally.pyx | 9 |
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)
|