Commit 7f3987e0 authored by gabrieldemarmiesse's avatar gabrieldemarmiesse

Moved an example for the rst file to the examples directory.

parent 084a25f5
from libc.stdio cimport FILE, fopen
def main():
cdef FILE* p
p = fopen("spam.txt", "r")
if p == NULL:
raise OSError("Couldn't open the spam file")
# ...
...@@ -479,12 +479,9 @@ returns ``NULL``. The except clause doesn't work that way; its only purpose is ...@@ -479,12 +479,9 @@ returns ``NULL``. The except clause doesn't work that way; its only purpose is
for propagating Python exceptions that have already been raised, either by a Cython for propagating Python exceptions that have already been raised, either by a Cython
function or a C function that calls Python/C API routines. To get an exception function or a C function that calls Python/C API routines. To get an exception
from a non-Python-aware function such as :func:`fopen`, you will have to check the from a non-Python-aware function such as :func:`fopen`, you will have to check the
return value and raise it yourself, for example,:: return value and raise it yourself, for example:
cdef FILE* p .. literalinclude:: ../../examples/userguide/language_basics/open_file.pyx
p = fopen("spam.txt", "r")
if p == NULL:
raise SpamError("Couldn't open the spam file")
.. _overriding_in_extension_types: .. _overriding_in_extension_types:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment