]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-38650: Constify PyStructSequence_UnnamedField. (GH-17005)
authorSerhiy Storchaka <storchaka@gmail.com>
Sat, 16 Nov 2019 16:55:29 +0000 (18:55 +0200)
committerGitHub <noreply@github.com>
Sat, 16 Nov 2019 16:55:29 +0000 (18:55 +0200)
Make it a constant and referring to a constant string.

Doc/c-api/tuple.rst
Doc/whatsnew/3.9.rst
Include/structseq.h
Misc/NEWS.d/next/C API/2019-10-30-22-03-03.bpo-38650.0pi8zt.rst [new file with mode: 0644]
Objects/structseq.c

index 25df3974e870e2cbaf399d455290653ed76983d6..62bc9a565071d340f3a9508d102a6fe216b71b2d 100644 (file)
@@ -182,10 +182,13 @@ type.
    +-----------+------------------+-----------------------------------------+
 
 
-.. c:var:: char* PyStructSequence_UnnamedField
+.. c:var:: const char * const PyStructSequence_UnnamedField
 
    Special value for a field name to leave it unnamed.
 
+   .. versionchanged:: 3.9
+      The type was changed from ``char *``.
+
 
 .. c:function:: PyObject* PyStructSequence_New(PyTypeObject *type)
 
index b1beb0be090cfa89d461d8d750500bbffbd8d6b5..6e9ddc56840455196d0747b5977f72db4d5c6c3a 100644 (file)
@@ -215,6 +215,9 @@ Build and C API Changes
   way to call a callable Python object without any argument.
   (Contributed by Victor Stinner in :issue:`37194`.)
 
+* The global variable :c:data:`PyStructSequence_UnnamedField` is now a constant
+  and refers to a constant string.
+  (Contributed by Serhiy Storchaka in :issue:`38650`.)
 
 
 Deprecated
index e5e5d5c5735e9d5dc79d3417c09be5a1e7556d3f..8f51c89163a4e17ef188001de6d9fa53d70b97ad 100644 (file)
@@ -19,7 +19,7 @@ typedef struct PyStructSequence_Desc {
     int n_in_sequence;
 } PyStructSequence_Desc;
 
-extern char* PyStructSequence_UnnamedField;
+extern const char * const PyStructSequence_UnnamedField;
 
 #ifndef Py_LIMITED_API
 PyAPI_FUNC(void) PyStructSequence_InitType(PyTypeObject *type,
diff --git a/Misc/NEWS.d/next/C API/2019-10-30-22-03-03.bpo-38650.0pi8zt.rst b/Misc/NEWS.d/next/C API/2019-10-30-22-03-03.bpo-38650.0pi8zt.rst
new file mode 100644 (file)
index 0000000..55b9c13
--- /dev/null
@@ -0,0 +1,2 @@
+The global variable :c:data:`PyStructSequence_UnnamedField` is now a
+constant and refers to a constant string.
index c158afccb97fdde8d562226e178e5e88e2754437..c86fbe50b972c6999182f3409ef3d104e580b1bb 100644 (file)
@@ -18,7 +18,7 @@ static const char unnamed_fields_key[] = "n_unnamed_fields";
 
 /* Fields with this name have only a field index, not a field name.
    They are only allowed for indices < n_visible_fields. */
-char *PyStructSequence_UnnamedField = "unnamed field";
+const char * const PyStructSequence_UnnamedField = "unnamed field";
 _Py_IDENTIFIER(n_sequence_fields);
 _Py_IDENTIFIER(n_fields);
 _Py_IDENTIFIER(n_unnamed_fields);