@@ -25,12 +25,16 @@ pointers. This is consistent throughout the API.
2525
2626 The C structure which corresponds to the value portion of a Python complex
2727 number object. Most of the functions for dealing with complex number objects
28- use structures of this type as input or output values, as appropriate. It is
29- defined as::
28+ use structures of this type as input or output values, as appropriate.
29+
30+ .. c :member :: double real
31+ double imag
32+
33+ The structure is defined as::
3034
3135 typedef struct {
32- double real;
33- double imag;
36+ double real;
37+ double imag;
3438 } Py_complex;
3539
3640
@@ -106,17 +110,22 @@ Complex Numbers as Python Objects
106110.. c :function :: PyObject* PyComplex_FromCComplex (Py_complex v)
107111
108112 Create a new Python complex number object from a C :c:type:`Py_complex` value.
113+ Return ``NULL`` with an exception set on error.
109114
110115
111116.. c:function:: PyObject* PyComplex_FromDoubles(double real, double imag)
112117
113118 Return a new :c:type:`PyComplexObject` object from *real* and *imag*.
119+ Return ``NULL`` with an exception set on error.
114120
115121
116122.. c:function:: double PyComplex_RealAsDouble(PyObject *op)
117123
118124 Return the real part of *op * as a C :c:expr: `double `.
119125
126+ Upon failure, this method returns ``-1.0 `` with an exception set, so one
127+ should call :c:func: `PyErr_Occurred ` to check for errors.
128+
120129
121130.. c :function :: double PyComplex_ImagAsDouble (PyObject *op)
122131
@@ -131,8 +140,11 @@ Complex Numbers as Python Objects
131140 method, this method will first be called to convert *op * to a Python complex
132141 number object. If :meth: `!__complex__ ` is not defined then it falls back to
133142 :meth: `~object.__float__ `. If :meth: `!__float__ ` is not defined then it falls back
134- to :meth: `~object.__index__ `. Upon failure, this method returns ``-1.0 `` as a real
135- value.
143+ to :meth: `~object.__index__ `.
144+
145+ Upon failure, this method returns :c:type: `Py_complex `
146+ with :c:member: `~Py_complex.real ` set to ``-1.0 `` and with an exception set, so one
147+ should call :c:func: `PyErr_Occurred ` to check for errors.
136148
137149 .. versionchanged :: 3.8
138150 Use :meth: `~object.__index__ ` if available.
0 commit comments