bpo-38650: Constify PyStructSequence_UnnamedField. (GH-17005)

Make it a constant and referring to a constant string.
This commit is contained in:
Serhiy Storchaka 2019-11-16 18:55:29 +02:00 committed by GitHub
parent 5fd5cb8d85
commit bd44a7ead9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 3 deletions

View 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)

View 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

View 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,

View File

@ -0,0 +1,2 @@
The global variable :c:data:`PyStructSequence_UnnamedField` is now a
constant and refers to a constant string.

View 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);