Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 007d7ff

Browse filesBrowse files
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 *".
1 parent 9af740b commit 007d7ff
Copy full SHA for 007d7ff

8 files changed

+31-21Lines changed: 31 additions & 21 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Doc/c-api/typeobj.rst‎

Copy file name to clipboardExpand all lines: Doc/c-api/typeobj.rst
+5-5Lines changed: 5 additions & 5 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -725,11 +725,11 @@ type objects) *must* have the :attr:`ob_size` field.
725725
typedef int (*setter)(PyObject *, PyObject *, void *);
726726

727727
typedef struct PyGetSetDef {
728-
char *name; /* attribute name */
729-
getter get; /* C function to get the attribute */
730-
setter set; /* C function to set or delete the attribute */
731-
char *doc; /* optional doc string */
732-
void *closure; /* optional additional data for getter and setter */
728+
const char *name; /* attribute name */
729+
getter get; /* C function to get the attribute */
730+
setter set; /* C function to set or delete the attribute */
731+
const char *doc; /* optional doc string */
732+
void *closure; /* optional additional data for getter and setter */
733733
} PyGetSetDef;
734734

735735

Collapse file

‎Doc/extending/newtypes.rst‎

Copy file name to clipboardExpand all lines: Doc/extending/newtypes.rst
+5-5Lines changed: 5 additions & 5 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1138,11 +1138,11 @@ in the instance. A variety of primitive C types are supported, and access may
11381138
be read-only or read-write. The structures in the table are defined as::
11391139

11401140
typedef struct PyMemberDef {
1141-
char *name;
1142-
int type;
1143-
int offset;
1144-
int flags;
1145-
char *doc;
1141+
const char *name;
1142+
int type;
1143+
int offset;
1144+
int flags;
1145+
const char *doc;
11461146
} PyMemberDef;
11471147

11481148
For each entry in the table, a :term:`descriptor` will be constructed and added to the
Collapse file

‎Doc/whatsnew/3.7.rst‎

Copy file name to clipboardExpand all lines: Doc/whatsnew/3.7.rst
+6Lines changed: 6 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ Build and C API Changes
9999
of libffi is now required when building ``_ctypes`` on such platforms.
100100
Contributed by Zachary Ware in :issue:`27979`.
101101

102+
* The fields :c:member:`name` and :c:member:`doc` of structures
103+
:c:type:`PyMemberDef`, :c:type:`PyGetSetDef`,
104+
:c:type:`PyStructSequence_Field`, :c:type:`PyStructSequence_Desc`,
105+
and :c:type:`wrapperbase` are now of type ``const char *`` rather of
106+
``char *``. (Contributed by Serhiy Storchaka in :issue:`28761`.)
107+
102108

103109
Deprecated
104110
==========
Collapse file

‎Include/descrobject.h‎

Copy file name to clipboardExpand all lines: Include/descrobject.h
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ typedef PyObject *(*getter)(PyObject *, void *);
99
typedef int (*setter)(PyObject *, PyObject *, void *);
1010

1111
typedef struct PyGetSetDef {
12-
char *name;
12+
const char *name;
1313
getter get;
1414
setter set;
15-
char *doc;
15+
const char *doc;
1616
void *closure;
1717
} PyGetSetDef;
1818

@@ -24,11 +24,11 @@ typedef PyObject *(*wrapperfunc_kwds)(PyObject *self, PyObject *args,
2424
void *wrapped, PyObject *kwds);
2525

2626
struct wrapperbase {
27-
char *name;
27+
const char *name;
2828
int offset;
2929
void *function;
3030
wrapperfunc wrapper;
31-
char *doc;
31+
const char *doc;
3232
int flags;
3333
PyObject *name_strobj;
3434
};
Collapse file

‎Include/structmember.h‎

Copy file name to clipboardExpand all lines: Include/structmember.h
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ extern "C" {
1616
pointer is NULL. */
1717

1818
typedef struct PyMemberDef {
19-
char *name;
19+
const char *name;
2020
int type;
2121
Py_ssize_t offset;
2222
int flags;
23-
char *doc;
23+
const char *doc;
2424
} PyMemberDef;
2525

2626
/* Types */
Collapse file

‎Include/structseq.h‎

Copy file name to clipboardExpand all lines: Include/structseq.h
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ extern "C" {
88
#endif
99

1010
typedef struct PyStructSequence_Field {
11-
char *name;
12-
char *doc;
11+
const char *name;
12+
const char *doc;
1313
} PyStructSequence_Field;
1414

1515
typedef struct PyStructSequence_Desc {
16-
char *name;
17-
char *doc;
16+
const char *name;
17+
const char *doc;
1818
struct PyStructSequence_Field *fields;
1919
int n_in_sequence;
2020
} PyStructSequence_Desc;
Collapse file

‎Misc/NEWS‎

Copy file name to clipboardExpand all lines: Misc/NEWS
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,10 @@ Windows
432432
C API
433433
-----
434434

435+
- Issue #28761: The fields name and doc of structures PyMemberDef, PyGetSetDef,
436+
PyStructSequence_Field, PyStructSequence_Desc, and wrapperbase are now of
437+
type "const char *" rather of "char *".
438+
435439
- Issue #28748: Private variable _Py_PackageContext is now of type "const char *"
436440
rather of "char *".
437441

Collapse file

‎Objects/structseq.c‎

Copy file name to clipboardExpand all lines: Objects/structseq.c
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ structseq_reduce(PyStructSequence* self)
256256
}
257257

258258
for (; i < n_fields; i++) {
259-
char *n = Py_TYPE(self)->tp_members[i-n_unnamed_fields].name;
259+
const char *n = Py_TYPE(self)->tp_members[i-n_unnamed_fields].name;
260260
if (PyDict_SetItemString(dict, n, self->ob_item[i]) < 0)
261261
goto error;
262262
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.