diff options
author | Stefan Behnel <stefan_ml@behnel.de> | 2020-05-21 09:38:29 +0200 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2020-05-21 09:38:29 +0200 |
commit | 917dbeef5422b3ef49874d60bbb70c294c5c45e2 (patch) | |
tree | 0236de992d0da91cad4544de6de792440bce8af9 | |
parent | cb4c5229385ce6eb3ca6f7eedb9209995a3985a9 (diff) | |
download | cython-917dbeef5422b3ef49874d60bbb70c294c5c45e2.tar.gz |
Document "@exceptval" default for return type annotations.
See https://github.com/cython/cython/issues/3625
-rw-r--r-- | docs/src/tutorial/pure.rst | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/docs/src/tutorial/pure.rst b/docs/src/tutorial/pure.rst index 775e7719c..2ae589680 100644 --- a/docs/src/tutorial/pure.rst +++ b/docs/src/tutorial/pure.rst @@ -165,6 +165,13 @@ Static typing .. literalinclude:: ../../examples/tutorial/pure/exceptval.py + Note that the default exception handling behaviour when returning C numeric types + is to check for ``-1``, and if that was returned, check Python's error indicator + for an exception. This means, if no ``@exceptval`` decorator is provided, and the + return type is a numeric type, then the default with type annotations is + ``@exceptval(-1, check=True)``, in order to make sure that exceptions are correctly + and efficiently reported to the caller. + Since version 0.27, Cython also supports the variable annotations defined in `PEP 526 <https://www.python.org/dev/peps/pep-0526/>`_. This allows to declare types of variables in a Python 3.6 compatible way as follows: |