Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-38650: Constify PyStructSequence_UnnamedField. #17005

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion Doc/c-api/tuple.rst
Expand Up @@ -182,10 +182,13 @@ type.
+-----------+------------------+-----------------------------------------+


.. c:var:: char* PyStructSequence_UnnamedField
.. c:var:: const char * const PyStructSequence_UnnamedField
serhiy-storchaka marked this conversation as resolved.
Show resolved Hide resolved

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)

Expand Down
3 changes: 3 additions & 0 deletions Doc/whatsnew/3.9.rst
Expand Up @@ -195,6 +195,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
Expand Down
2 changes: 1 addition & 1 deletion Include/structseq.h
Expand Up @@ -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,
Expand Down
@@ -0,0 +1,2 @@
The global variable :c:data:`PyStructSequence_UnnamedField` is now a
constant and refers to a constant string.
2 changes: 1 addition & 1 deletion Objects/structseq.c
Expand Up @@ -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);
Expand Down