changeset: 105325:42b0ba372ec2 user: Serhiy Storchaka date: Tue Nov 22 07:58:08 2016 +0200 files: Doc/c-api/typeobj.rst Doc/extending/newtypes.rst Doc/whatsnew/3.7.rst Include/descrobject.h Include/structmember.h Include/structseq.h Misc/NEWS Objects/structseq.c description: Issue #28761: The fields name and doc of structures PyMemberDef, PyGetSetDef, PyStructSequence_Field, PyStructSequence_Desc, and wrapperbase are now of type "const char *" rather of "char *". diff -r a0da176233b9 -r 42b0ba372ec2 Doc/c-api/typeobj.rst --- a/Doc/c-api/typeobj.rst Mon Nov 21 17:24:58 2016 -0800 +++ b/Doc/c-api/typeobj.rst Tue Nov 22 07:58:08 2016 +0200 @@ -725,11 +725,11 @@ typedef int (*setter)(PyObject *, PyObject *, void *); typedef struct PyGetSetDef { - char *name; /* attribute name */ - getter get; /* C function to get the attribute */ - setter set; /* C function to set or delete the attribute */ - char *doc; /* optional doc string */ - void *closure; /* optional additional data for getter and setter */ + const char *name; /* attribute name */ + getter get; /* C function to get the attribute */ + setter set; /* C function to set or delete the attribute */ + const char *doc; /* optional doc string */ + void *closure; /* optional additional data for getter and setter */ } PyGetSetDef; diff -r a0da176233b9 -r 42b0ba372ec2 Doc/extending/newtypes.rst --- a/Doc/extending/newtypes.rst Mon Nov 21 17:24:58 2016 -0800 +++ b/Doc/extending/newtypes.rst Tue Nov 22 07:58:08 2016 +0200 @@ -1138,11 +1138,11 @@ be read-only or read-write. The structures in the table are defined as:: typedef struct PyMemberDef { - char *name; - int type; - int offset; - int flags; - char *doc; + const char *name; + int type; + int offset; + int flags; + const char *doc; } PyMemberDef; For each entry in the table, a :term:`descriptor` will be constructed and added to the diff -r a0da176233b9 -r 42b0ba372ec2 Doc/whatsnew/3.7.rst --- a/Doc/whatsnew/3.7.rst Mon Nov 21 17:24:58 2016 -0800 +++ b/Doc/whatsnew/3.7.rst Tue Nov 22 07:58:08 2016 +0200 @@ -99,6 +99,12 @@ of libffi is now required when building ``_ctypes`` on such platforms. Contributed by Zachary Ware in :issue:`27979`. +* The fields :c:member:`name` and :c:member:`doc` of structures + :c:type:`PyMemberDef`, :c:type:`PyGetSetDef`, + :c:type:`PyStructSequence_Field`, :c:type:`PyStructSequence_Desc`, + and :c:type:`wrapperbase` are now of type ``const char *`` rather of + ``char *``. (Contributed by Serhiy Storchaka in :issue:`28761`.) + Deprecated ========== diff -r a0da176233b9 -r 42b0ba372ec2 Include/descrobject.h --- a/Include/descrobject.h Mon Nov 21 17:24:58 2016 -0800 +++ b/Include/descrobject.h Tue Nov 22 07:58:08 2016 +0200 @@ -9,10 +9,10 @@ typedef int (*setter)(PyObject *, PyObject *, void *); typedef struct PyGetSetDef { - char *name; + const char *name; getter get; setter set; - char *doc; + const char *doc; void *closure; } PyGetSetDef; @@ -24,11 +24,11 @@ void *wrapped, PyObject *kwds); struct wrapperbase { - char *name; + const char *name; int offset; void *function; wrapperfunc wrapper; - char *doc; + const char *doc; int flags; PyObject *name_strobj; }; diff -r a0da176233b9 -r 42b0ba372ec2 Include/structmember.h --- a/Include/structmember.h Mon Nov 21 17:24:58 2016 -0800 +++ b/Include/structmember.h Tue Nov 22 07:58:08 2016 +0200 @@ -16,11 +16,11 @@ pointer is NULL. */ typedef struct PyMemberDef { - char *name; + const char *name; int type; Py_ssize_t offset; int flags; - char *doc; + const char *doc; } PyMemberDef; /* Types */ diff -r a0da176233b9 -r 42b0ba372ec2 Include/structseq.h --- a/Include/structseq.h Mon Nov 21 17:24:58 2016 -0800 +++ b/Include/structseq.h Tue Nov 22 07:58:08 2016 +0200 @@ -8,13 +8,13 @@ #endif typedef struct PyStructSequence_Field { - char *name; - char *doc; + const char *name; + const char *doc; } PyStructSequence_Field; typedef struct PyStructSequence_Desc { - char *name; - char *doc; + const char *name; + const char *doc; struct PyStructSequence_Field *fields; int n_in_sequence; } PyStructSequence_Desc; diff -r a0da176233b9 -r 42b0ba372ec2 Misc/NEWS --- a/Misc/NEWS Mon Nov 21 17:24:58 2016 -0800 +++ b/Misc/NEWS Tue Nov 22 07:58:08 2016 +0200 @@ -432,6 +432,10 @@ C API ----- +- Issue #28761: The fields name and doc of structures PyMemberDef, PyGetSetDef, + PyStructSequence_Field, PyStructSequence_Desc, and wrapperbase are now of + type "const char *" rather of "char *". + - Issue #28748: Private variable _Py_PackageContext is now of type "const char *" rather of "char *". diff -r a0da176233b9 -r 42b0ba372ec2 Objects/structseq.c --- a/Objects/structseq.c Mon Nov 21 17:24:58 2016 -0800 +++ b/Objects/structseq.c Tue Nov 22 07:58:08 2016 +0200 @@ -256,7 +256,7 @@ } for (; i < n_fields; i++) { - char *n = Py_TYPE(self)->tp_members[i-n_unnamed_fields].name; + const char *n = Py_TYPE(self)->tp_members[i-n_unnamed_fields].name; if (PyDict_SetItemString(dict, n, self->ob_item[i]) < 0) goto error; }