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 *".
This commit is contained in:
Serhiy Storchaka 2016-11-22 07:58:08 +02:00
parent 9af740b99a
commit 007d7ff73f
8 changed files with 31 additions and 21 deletions

View File

@ -725,10 +725,10 @@ type objects) *must* have the :attr:`ob_size` field.
typedef int (*setter)(PyObject *, PyObject *, void *); typedef int (*setter)(PyObject *, PyObject *, void *);
typedef struct PyGetSetDef { typedef struct PyGetSetDef {
char *name; /* attribute name */ const char *name; /* attribute name */
getter get; /* C function to get the attribute */ getter get; /* C function to get the attribute */
setter set; /* C function to set or delete the attribute */ setter set; /* C function to set or delete the attribute */
char *doc; /* optional doc string */ const char *doc; /* optional doc string */
void *closure; /* optional additional data for getter and setter */ void *closure; /* optional additional data for getter and setter */
} PyGetSetDef; } PyGetSetDef;

View File

@ -1138,11 +1138,11 @@ in the instance. A variety of primitive C types are supported, and access may
be read-only or read-write. The structures in the table are defined as:: be read-only or read-write. The structures in the table are defined as::
typedef struct PyMemberDef { typedef struct PyMemberDef {
char *name; const char *name;
int type; int type;
int offset; int offset;
int flags; int flags;
char *doc; const char *doc;
} PyMemberDef; } PyMemberDef;
For each entry in the table, a :term:`descriptor` will be constructed and added to the For each entry in the table, a :term:`descriptor` will be constructed and added to the

View File

@ -99,6 +99,12 @@ Build and C API Changes
of libffi is now required when building ``_ctypes`` on such platforms. of libffi is now required when building ``_ctypes`` on such platforms.
Contributed by Zachary Ware in :issue:`27979`. 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 Deprecated
========== ==========

View File

@ -9,10 +9,10 @@ typedef PyObject *(*getter)(PyObject *, void *);
typedef int (*setter)(PyObject *, PyObject *, void *); typedef int (*setter)(PyObject *, PyObject *, void *);
typedef struct PyGetSetDef { typedef struct PyGetSetDef {
char *name; const char *name;
getter get; getter get;
setter set; setter set;
char *doc; const char *doc;
void *closure; void *closure;
} PyGetSetDef; } PyGetSetDef;
@ -24,11 +24,11 @@ typedef PyObject *(*wrapperfunc_kwds)(PyObject *self, PyObject *args,
void *wrapped, PyObject *kwds); void *wrapped, PyObject *kwds);
struct wrapperbase { struct wrapperbase {
char *name; const char *name;
int offset; int offset;
void *function; void *function;
wrapperfunc wrapper; wrapperfunc wrapper;
char *doc; const char *doc;
int flags; int flags;
PyObject *name_strobj; PyObject *name_strobj;
}; };

View File

@ -16,11 +16,11 @@ extern "C" {
pointer is NULL. */ pointer is NULL. */
typedef struct PyMemberDef { typedef struct PyMemberDef {
char *name; const char *name;
int type; int type;
Py_ssize_t offset; Py_ssize_t offset;
int flags; int flags;
char *doc; const char *doc;
} PyMemberDef; } PyMemberDef;
/* Types */ /* Types */

View File

@ -8,13 +8,13 @@ extern "C" {
#endif #endif
typedef struct PyStructSequence_Field { typedef struct PyStructSequence_Field {
char *name; const char *name;
char *doc; const char *doc;
} PyStructSequence_Field; } PyStructSequence_Field;
typedef struct PyStructSequence_Desc { typedef struct PyStructSequence_Desc {
char *name; const char *name;
char *doc; const char *doc;
struct PyStructSequence_Field *fields; struct PyStructSequence_Field *fields;
int n_in_sequence; int n_in_sequence;
} PyStructSequence_Desc; } PyStructSequence_Desc;

View File

@ -432,6 +432,10 @@ Windows
C API 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 *" - Issue #28748: Private variable _Py_PackageContext is now of type "const char *"
rather of "char *". rather of "char *".

View File

@ -256,7 +256,7 @@ structseq_reduce(PyStructSequence* self)
} }
for (; i < n_fields; i++) { 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) if (PyDict_SetItemString(dict, n, self->ob_item[i]) < 0)
goto error; goto error;
} }