Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 07b1c87

Browse files
committed
Issue #13522: document error return values of some float and complex C API functions.
1 parent bb2e9c4 commit 07b1c87

3 files changed

Lines changed: 10 additions & 1 deletion

File tree

Doc/c-api/complex.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,18 @@ pointers. This is consistent throughout the API.
6363
Return the quotient of two complex numbers, using the C :c:type:`Py_complex`
6464
representation.
6565
66+
If *divisor* is null, this method returns zero and sets
67+
:c:data:`errno` to :c:data:`EDOM`.
68+
6669
6770
.. c:function:: Py_complex _Py_c_pow(Py_complex num, Py_complex exp)
6871
6972
Return the exponentiation of *num* by *exp*, using the C :c:type:`Py_complex`
7073
representation.
7174
75+
If :attr:`exp.imag` is not null, or :attr:`exp.real` is negative,
76+
this method returns zero and sets :c:data:`errno` to :c:data:`EDOM`.
77+
7278
7379
Complex Numbers as Python Objects
7480
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -123,4 +129,4 @@ Complex Numbers as Python Objects
123129
124130
If *op* is not a Python complex number object but has a :meth:`__complex__`
125131
method, this method will first be called to convert *op* to a Python complex
126-
number object.
132+
number object. Upon failure, this method returns ``-1.0`` as a real value.

Doc/c-api/float.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ Floating Point Objects
4747
Return a C :c:type:`double` representation of the contents of *pyfloat*. If
4848
*pyfloat* is not a Python floating point object but has a :meth:`__float__`
4949
method, this method will first be called to convert *pyfloat* into a float.
50+
This method returns ``-1.0`` upon failure, so one should call
51+
:c:func:`PyErr_Occurred` to check for errors.
5052
5153
5254
.. c:function:: double PyFloat_AS_DOUBLE(PyObject *pyfloat)

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ Tarn Weisner Burton
139139
Lee Busby
140140
Ralph Butler
141141
Jp Calderone
142+
Arnaud Calmettes
142143
Daniel Calvelo
143144
Tony Campbell
144145
Brett Cannon

0 commit comments

Comments
 (0)