https://github.com/python/cpython/commit/9743d069bd53e9d3a8f09df899ec1c906a79da24
commit: 9743d069bd53e9d3a8f09df899ec1c906a79da24
branch: main
author: Sergey B Kirpichev <[email protected]>
committer: vstinner <[email protected]>
date: 2025-08-08T10:36:42Z
summary:

gh-128813: deprecate cval field of the PyComplexObject struct (#137271)

Co-authored-by: Petr Viktorin <[email protected]>
Co-authored-by: Victor Stinner <[email protected]>

files:
A Doc/deprecations/c-api-pending-removal-in-3.20.rst
M Doc/c-api/complex.rst
M Doc/deprecations/index.rst
M Doc/whatsnew/3.15.rst
M Misc/NEWS.d/next/C_API/2025-07-31-04-30-42.gh-issue-128813.opL-Pv.rst

diff --git a/Doc/c-api/complex.rst b/Doc/c-api/complex.rst
index 34488848f87cd1..a1fd27ad0acd2e 100644
--- a/Doc/c-api/complex.rst
+++ b/Doc/c-api/complex.rst
@@ -118,6 +118,16 @@ Complex Numbers as Python Objects
 
    This subtype of :c:type:`PyObject` represents a Python complex number 
object.
 
+   .. c:member:: Py_complex cval
+
+      The complex number value, using the C :c:type:`Py_complex` 
representation.
+
+      .. deprecated-removed:: next 3.20
+         Use :c:func:`PyComplex_AsCComplex` and
+         :c:func:`PyComplex_FromCComplex` to convert a
+         Python complex number to/from the C :c:type:`Py_complex`
+         representation.
+
 
 .. c:var:: PyTypeObject PyComplex_Type
 
diff --git a/Doc/deprecations/c-api-pending-removal-in-3.20.rst 
b/Doc/deprecations/c-api-pending-removal-in-3.20.rst
new file mode 100644
index 00000000000000..82f975d6ed4020
--- /dev/null
+++ b/Doc/deprecations/c-api-pending-removal-in-3.20.rst
@@ -0,0 +1,7 @@
+Pending removal in Python 3.20
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+* The ``cval`` field in :c:type:`PyComplexObject` (:gh:`128813`).
+  Use :c:func:`PyComplex_AsCComplex` and :c:func:`PyComplex_FromCComplex`
+  to convert a Python complex number to/from the C :c:type:`Py_complex`
+  representation.
diff --git a/Doc/deprecations/index.rst b/Doc/deprecations/index.rst
index d064f2bec42c22..c6e05c176b2aa1 100644
--- a/Doc/deprecations/index.rst
+++ b/Doc/deprecations/index.rst
@@ -18,4 +18,6 @@ C API deprecations
 
 .. include:: c-api-pending-removal-in-3.18.rst
 
+.. include:: c-api-pending-removal-in-3.20.rst
+
 .. include:: c-api-pending-removal-in-future.rst
diff --git a/Doc/whatsnew/3.15.rst b/Doc/whatsnew/3.15.rst
index 89644a509a0bb4..93f56eed857068 100644
--- a/Doc/whatsnew/3.15.rst
+++ b/Doc/whatsnew/3.15.rst
@@ -570,6 +570,13 @@ Deprecated C APIs
   signed integer type of the same size is now deprecated.
   (Contributed by Serhiy Storchaka in :gh:`132629`.)
 
+* Deprecate :c:member:`~PyComplexObject.cval` field of the the
+  :c:type:`PyComplexObject` type.
+  Use :c:func:`PyComplex_AsCComplex` and :c:func:`PyComplex_FromCComplex`
+  to convert a Python complex number to/from the C :c:type:`Py_complex`
+  representation.
+  (Contributed by Sergey B Kirpichev in :gh:`128813`.)
+
 * Functions :c:func:`_Py_c_sum`, :c:func:`_Py_c_diff`, :c:func:`_Py_c_neg`,
   :c:func:`_Py_c_prod`, :c:func:`_Py_c_quot`, :c:func:`_Py_c_pow` and
   :c:func:`_Py_c_abs` are :term:`soft deprecated`.
diff --git 
a/Misc/NEWS.d/next/C_API/2025-07-31-04-30-42.gh-issue-128813.opL-Pv.rst 
b/Misc/NEWS.d/next/C_API/2025-07-31-04-30-42.gh-issue-128813.opL-Pv.rst
index 625989b33704a7..caa8f3e9c985cd 100644
--- a/Misc/NEWS.d/next/C_API/2025-07-31-04-30-42.gh-issue-128813.opL-Pv.rst
+++ b/Misc/NEWS.d/next/C_API/2025-07-31-04-30-42.gh-issue-128813.opL-Pv.rst
@@ -1,4 +1,5 @@
 Functions :c:func:`_Py_c_sum`, :c:func:`_Py_c_diff`, :c:func:`_Py_c_neg`,
-:c:func:`_Py_c_prod`, :c:func:`_Py_c_quot`, :c:func:`_Py_c_pow` and
-previously undocumented :c:func:`_Py_c_abs` are :term:`soft deprecated`.
+:c:func:`_Py_c_prod`, :c:func:`_Py_c_quot`, :c:func:`_Py_c_pow` and previously
+undocumented :c:func:`_Py_c_abs` are :term:`soft deprecated`.  Deprecate also
+:c:member:`~PyComplexObject.cval` field of the :c:type:`PyComplexObject` type.
 Patch by Sergey B Kirpichev.

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to