diff --git a/Doc/c-api/structures.rst b/Doc/c-api/structures.rst index da45da1d3c70dbc..e11d5b6248fdfe8 100644 --- a/Doc/c-api/structures.rst +++ b/Doc/c-api/structures.rst @@ -290,11 +290,11 @@ definition with the same method name. handles use of the :keyword:`del` statement on that attribute more correctly than :c:macro:`T_OBJECT`. - :attr:`flags` can be ``0`` for write and read access or :c:macro:`READONLY` for - read-only access. Using :c:macro:`T_STRING` for :attr:`type` implies - :c:macro:`READONLY`. :c:macro:`T_STRING` data is interpreted as UTF-8. - Only :c:macro:`T_OBJECT` and :c:macro:`T_OBJECT_EX` - members can be deleted. (They are set to *NULL*). + :attr:`flags` can be ``0`` for write and read access (also represented by the + :c:macro:`PY_READWRITE`) or :c:macro:`PY_READONLY` for read-only access. Using + :c:macro:`T_STRING` for :attr:`type` implies :c:macro:`PY_READONLY`. + :c:macro:`T_STRING` data is interpreted as UTF-8. Only :c:macro:`T_OBJECT` + and :c:macro:`T_OBJECT_EX` members can be deleted. (They are set to *NULL*). .. c:type:: PyGetSetDef diff --git a/Doc/extending/newtypes.rst b/Doc/extending/newtypes.rst index 8b9549d7e39e2e3..b88e6a5767985fd 100644 --- a/Doc/extending/newtypes.rst +++ b/Doc/extending/newtypes.rst @@ -282,23 +282,26 @@ store flags which control how the attribute can be accessed. The following flag constants are defined in :file:`structmember.h`; they may be combined using bitwise-OR. -+---------------------------+----------------------------------------------+ -| Constant | Meaning | -+===========================+==============================================+ -| :const:`READONLY` | Never writable. | -+---------------------------+----------------------------------------------+ -| :const:`READ_RESTRICTED` | Not readable in restricted mode. | -+---------------------------+----------------------------------------------+ -| :const:`WRITE_RESTRICTED` | Not writable in restricted mode. | -+---------------------------+----------------------------------------------+ -| :const:`RESTRICTED` | Not readable or writable in restricted mode. | -+---------------------------+----------------------------------------------+ ++------------------------------+----------------------------------------------+---------------------------+ +| Constant | Meaning | Former Constant | ++==============================+==============================================+===========================+ +| :const:`PY_READWRITE` | Writable. | 0 | ++------------------------------+----------------------------------------------+---------------------------+ +| :const:`PY_READONLY` | Never writable. | :const:`READONLY` | ++------------------------------+----------------------------------------------+---------------------------+ +| :const:`PY_READ_RESTRICTED` | Not readable in restricted mode. | :const:`READ_RESTRICTED` | ++------------------------------+----------------------------------------------+---------------------------+ +| :const:`PY_WRITE_RESTRICTED` | Not writable in restricted mode. | :const:`WRITE_RESTRICTED` | ++------------------------------+----------------------------------------------+---------------------------+ +| :const:`PY_RESTRICTED` | Not readable or writable in restricted mode. | :const:`RESTRICTED` | ++------------------------------+----------------------------------------------+---------------------------+ .. index:: - single: READONLY - single: READ_RESTRICTED - single: WRITE_RESTRICTED - single: RESTRICTED + single: PY_READWRITE + single: PY_READONLY + single: PY_READ_RESTRICTED + single: PY_WRITE_RESTRICTED + single: PY_RESTRICTED An interesting advantage of using the :c:member:`~PyTypeObject.tp_members` table to build descriptors that are used at runtime is that any attribute defined this way can diff --git a/Doc/extending/newtypes_tutorial.rst b/Doc/extending/newtypes_tutorial.rst index bb8a40d0fb06f50..a67e614a3699d81 100644 --- a/Doc/extending/newtypes_tutorial.rst +++ b/Doc/extending/newtypes_tutorial.rst @@ -429,11 +429,11 @@ We want to expose our instance variables as attributes. There are a number of ways to do that. The simplest way is to define member definitions:: static PyMemberDef Custom_members[] = { - {"first", T_OBJECT_EX, offsetof(CustomObject, first), 0, + {"first", T_OBJECT_EX, offsetof(CustomObject, first), PY_READWRITE, "first name"}, - {"last", T_OBJECT_EX, offsetof(CustomObject, last), 0, + {"last", T_OBJECT_EX, offsetof(CustomObject, last), PY_READWRITE, "last name"}, - {"number", T_INT, offsetof(CustomObject, number), 0, + {"number", T_INT, offsetof(CustomObject, number), PY_READWRITE, "custom number"}, {NULL} /* Sentinel */ }; @@ -602,7 +602,7 @@ above. In this case, we aren't using a closure, so we just pass *NULL*. We also remove the member definitions for these attributes:: static PyMemberDef Custom_members[] = { - {"number", T_INT, offsetof(CustomObject, number), 0, + {"number", T_INT, offsetof(CustomObject, number), PY_READWRITE, "custom number"}, {NULL} /* Sentinel */ }; diff --git a/Doc/includes/custom2.c b/Doc/includes/custom2.c index 51ab4b80d680980..f194d43b4e10403 100644 --- a/Doc/includes/custom2.c +++ b/Doc/includes/custom2.c @@ -64,11 +64,11 @@ Custom_init(CustomObject *self, PyObject *args, PyObject *kwds) } static PyMemberDef Custom_members[] = { - {"first", T_OBJECT_EX, offsetof(CustomObject, first), 0, + {"first", T_OBJECT_EX, offsetof(CustomObject, first), PY_READWRITE, "first name"}, - {"last", T_OBJECT_EX, offsetof(CustomObject, last), 0, + {"last", T_OBJECT_EX, offsetof(CustomObject, last), PY_READWRITE, "last name"}, - {"number", T_INT, offsetof(CustomObject, number), 0, + {"number", T_INT, offsetof(CustomObject, number), PY_READWRITE, "custom number"}, {NULL} /* Sentinel */ }; diff --git a/Doc/includes/custom3.c b/Doc/includes/custom3.c index 09e87355b91afa2..57ad6434cd40409 100644 --- a/Doc/includes/custom3.c +++ b/Doc/includes/custom3.c @@ -64,7 +64,7 @@ Custom_init(CustomObject *self, PyObject *args, PyObject *kwds) } static PyMemberDef Custom_members[] = { - {"number", T_INT, offsetof(CustomObject, number), 0, + {"number", T_INT, offsetof(CustomObject, number), PY_READWRITE, "custom number"}, {NULL} /* Sentinel */ }; diff --git a/Doc/includes/custom4.c b/Doc/includes/custom4.c index 0994d8fda0e51fa..6df4a06f6961e80 100644 --- a/Doc/includes/custom4.c +++ b/Doc/includes/custom4.c @@ -80,7 +80,7 @@ Custom_init(CustomObject *self, PyObject *args, PyObject *kwds) } static PyMemberDef Custom_members[] = { - {"number", T_INT, offsetof(CustomObject, number), 0, + {"number", T_INT, offsetof(CustomObject, number), PY_READWRITE, "custom number"}, {NULL} /* Sentinel */ }; diff --git a/Include/structmember.h b/Include/structmember.h index b54f7081f458dd9..32ca648dfe9e879 100644 --- a/Include/structmember.h +++ b/Include/structmember.h @@ -11,7 +11,7 @@ extern "C" { /* An array of PyMemberDef structures defines the name, type and offset of selected members of a C structure. These can be read by - PyMember_GetOne() and set by PyMember_SetOne() (except if their READONLY + PyMember_GetOne() and set by PyMember_SetOne() (except if their PY_READONLY flag is set). The array must be terminated with an entry whose name pointer is NULL. */ @@ -57,10 +57,17 @@ typedef struct PyMemberDef { /* Flags */ -#define READONLY 1 -#define READ_RESTRICTED 2 -#define PY_WRITE_RESTRICTED 4 -#define RESTRICTED (READ_RESTRICTED | PY_WRITE_RESTRICTED) +#define PY_READWRITE 0 +#define PY_READONLY 1 +#define PY_READ_RESTRICTED 2 +#define PY_WRITE_RESTRICTED 4 +#define PY_RESTRICTED (PY_READ_RESTRICTED | PY_WRITE_RESTRICTED) + +/* Flags defined for the backward compatibility */ +#define READWRITE PY_READWRITE +#define READONLY PY_READONLY +#define READ_RESTRICTED PY_READ_RESTRICTED +#define RESTRICTED PY_RESTRICTED /* Current API, use this */ diff --git a/Misc/NEWS.d/next/Core and Builtins/2019-03-18-15-44-50.bpo-36347.tpMZfJ.rst b/Misc/NEWS.d/next/Core and Builtins/2019-03-18-15-44-50.bpo-36347.tpMZfJ.rst new file mode 100644 index 000000000000000..5479425f9d60649 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2019-03-18-15-44-50.bpo-36347.tpMZfJ.rst @@ -0,0 +1,3 @@ +Add :c:macro:`PY_READWRITE` for a more explicit definition of the +:c:type:`PyMemberDef` members and add the prefix ``PY_`` to these constants. +Contributed by Stéphane Wirtel. diff --git a/Modules/_bz2module.c b/Modules/_bz2module.c index b5e5a79d50a5bb4..829ec9454d0648f 100644 --- a/Modules/_bz2module.c +++ b/Modules/_bz2module.c @@ -676,10 +676,10 @@ PyDoc_STRVAR(BZ2Decompressor_needs_input_doc, static PyMemberDef BZ2Decompressor_members[] = { {"eof", T_BOOL, offsetof(BZ2Decompressor, eof), - READONLY, BZ2Decompressor_eof__doc__}, + PY_READONLY, BZ2Decompressor_eof__doc__}, {"unused_data", T_OBJECT_EX, offsetof(BZ2Decompressor, unused_data), - READONLY, BZ2Decompressor_unused_data__doc__}, - {"needs_input", T_BOOL, offsetof(BZ2Decompressor, needs_input), READONLY, + PY_READONLY, BZ2Decompressor_unused_data__doc__}, + {"needs_input", T_BOOL, offsetof(BZ2Decompressor, needs_input), PY_READONLY, BZ2Decompressor_needs_input_doc}, {NULL} }; diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c index a40b681d2835f53..2a3646b34a13cf1 100644 --- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@ -2072,7 +2072,7 @@ static PyMethodDef defdict_methods[] = { static PyMemberDef defdict_members[] = { {"default_factory", T_OBJECT, - offsetof(defdictobject, default_factory), 0, + offsetof(defdictobject, default_factory), PY_READWRITE, PyDoc_STR("Factory for default value called by __missing__().")}, {NULL} }; @@ -2448,7 +2448,7 @@ tuplegetter_reduce(_tuplegetterobject *self, PyObject *Py_UNUSED(ignored)) static PyMemberDef tuplegetter_members[] = { - {"__doc__", T_OBJECT, offsetof(_tuplegetterobject, doc), 0}, + {"__doc__", T_OBJECT, offsetof(_tuplegetterobject, doc), PY_READWRITE}, {0} }; diff --git a/Modules/_csv.c b/Modules/_csv.c index d86f63ef597610c..0cdcfc68a658dc8 100644 --- a/Modules/_csv.c +++ b/Modules/_csv.c @@ -293,9 +293,9 @@ dialect_check_quoting(int quoting) #define D_OFF(x) offsetof(DialectObj, x) static struct PyMemberDef Dialect_memberlist[] = { - { "skipinitialspace", T_BOOL, D_OFF(skipinitialspace), READONLY }, - { "doublequote", T_BOOL, D_OFF(doublequote), READONLY }, - { "strict", T_BOOL, D_OFF(strict), READONLY }, + { "skipinitialspace", T_BOOL, D_OFF(skipinitialspace), PY_READONLY }, + { "doublequote", T_BOOL, D_OFF(doublequote), PY_READONLY }, + { "strict", T_BOOL, D_OFF(strict), PY_READONLY }, { NULL } }; @@ -889,8 +889,8 @@ static struct PyMethodDef Reader_methods[] = { #define R_OFF(x) offsetof(ReaderObj, x) static struct PyMemberDef Reader_memberlist[] = { - { "dialect", T_OBJECT, R_OFF(dialect), READONLY }, - { "line_num", T_ULONG, R_OFF(line_num), READONLY }, + { "dialect", T_OBJECT, R_OFF(dialect), PY_READONLY }, + { "line_num", T_ULONG, R_OFF(line_num), PY_READONLY }, { NULL } }; @@ -1285,7 +1285,7 @@ static struct PyMethodDef Writer_methods[] = { #define W_OFF(x) offsetof(WriterObj, x) static struct PyMemberDef Writer_memberlist[] = { - { "dialect", T_OBJECT, W_OFF(dialect), READONLY }, + { "dialect", T_OBJECT, W_OFF(dialect), PY_READONLY }, { NULL } }; diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index 0d95d2b6f76eceb..8b1c071fe3ccc70 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -2666,13 +2666,13 @@ PyCData_dealloc(PyObject *self) static PyMemberDef PyCData_members[] = { { "_b_base_", T_OBJECT, - offsetof(CDataObject, b_base), READONLY, + offsetof(CDataObject, b_base), PY_READONLY, "the base object" }, { "_b_needsfree_", T_INT, - offsetof(CDataObject, b_needsfree), READONLY, + offsetof(CDataObject, b_needsfree), PY_READONLY, "whether the object owns the memory or not" }, { "_objects", T_OBJECT, - offsetof(CDataObject, b_objects), READONLY, + offsetof(CDataObject, b_objects), PY_READONLY, "internal objects tree (NEVER CHANGE THIS OBJECT!)"}, { NULL }, }; diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c index d91e84613b2fe11..0cc4d6180b93527 100644 --- a/Modules/_ctypes/callproc.c +++ b/Modules/_ctypes/callproc.c @@ -544,7 +544,7 @@ PyCArg_repr(PyCArgObject *self) static PyMemberDef PyCArgType_members[] = { { "_obj", T_OBJECT, - offsetof(PyCArgObject, obj), READONLY, + offsetof(PyCArgObject, obj), PY_READONLY, "the wrapped object" }, { NULL }, }; diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c index c1557b5e6f491df..b4df9d888713f8d 100644 --- a/Modules/_datetimemodule.c +++ b/Modules/_datetimemodule.c @@ -2650,13 +2650,13 @@ delta_reduce(PyDateTime_Delta* self, PyObject *Py_UNUSED(ignored)) static PyMemberDef delta_members[] = { - {"days", T_INT, OFFSET(days), READONLY, + {"days", T_INT, OFFSET(days), PY_READONLY, PyDoc_STR("Number of days.")}, - {"seconds", T_INT, OFFSET(seconds), READONLY, + {"seconds", T_INT, OFFSET(seconds), PY_READONLY, PyDoc_STR("Number of seconds (>= 0 and less than 1 day).")}, - {"microseconds", T_INT, OFFSET(microseconds), READONLY, + {"microseconds", T_INT, OFFSET(microseconds), PY_READONLY, PyDoc_STR("Number of microseconds (>= 0 and less than 1 second).")}, {NULL} }; diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c index 1e58cd05b512371..9321e2c77b60fe1 100644 --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -3753,8 +3753,8 @@ _elementtree_XMLParser__setevents_impl(XMLParserObject *self, } static PyMemberDef xmlparser_members[] = { - {"entity", T_OBJECT, offsetof(XMLParserObject, entity), READONLY, NULL}, - {"target", T_OBJECT, offsetof(XMLParserObject, target), READONLY, NULL}, + {"entity", T_OBJECT, offsetof(XMLParserObject, entity), PY_READONLY, NULL}, + {"target", T_OBJECT, offsetof(XMLParserObject, target), PY_READONLY, NULL}, {NULL} }; diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c index 3f1c01651ded1bd..c6b5b0ff1310dd0 100644 --- a/Modules/_functoolsmodule.c +++ b/Modules/_functoolsmodule.c @@ -249,11 +249,11 @@ PyDoc_STRVAR(partial_doc, #define OFF(x) offsetof(partialobject, x) static PyMemberDef partial_memberlist[] = { - {"func", T_OBJECT, OFF(fn), READONLY, + {"func", T_OBJECT, OFF(fn), PY_READONLY, "function object to use in future partial calls"}, - {"args", T_OBJECT, OFF(args), READONLY, + {"args", T_OBJECT, OFF(args), PY_READONLY, "tuple of arguments to future partial calls"}, - {"keywords", T_OBJECT, OFF(kw), READONLY, + {"keywords", T_OBJECT, OFF(kw), PY_READONLY, "dictionary of keyword arguments to future partial calls"}, {NULL} /* Sentinel */ }; @@ -460,7 +460,7 @@ keyobject_clear(keyobject *ko) static PyMemberDef keyobject_members[] = { {"obj", T_OBJECT, - offsetof(keyobject, object), 0, + offsetof(keyobject, object), PY_READWRITE, PyDoc_STR("Value wrapped by a key function.")}, {NULL} }; diff --git a/Modules/_hashopenssl.c b/Modules/_hashopenssl.c index e560c18b63c348c..1e2949c500819d9 100644 --- a/Modules/_hashopenssl.c +++ b/Modules/_hashopenssl.c @@ -320,7 +320,7 @@ EVP_get_digest_size(EVPobject *self, void *closure) } static PyMemberDef EVP_members[] = { - {"name", T_OBJECT, offsetof(EVPobject, name), READONLY, PyDoc_STR("algorithm name.")}, + {"name", T_OBJECT, offsetof(EVPobject, name), PY_READONLY, PyDoc_STR("algorithm name.")}, {NULL} /* Sentinel */ }; diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c index 6f855b9edd08428..267d4dfefeda1a5 100644 --- a/Modules/_io/bufferedio.c +++ b/Modules/_io/bufferedio.c @@ -2400,8 +2400,8 @@ static PyMethodDef bufferedreader_methods[] = { }; static PyMemberDef bufferedreader_members[] = { - {"raw", T_OBJECT, offsetof(buffered, raw), READONLY}, - {"_finalizing", T_BOOL, offsetof(buffered, finalizing), 0}, + {"raw", T_OBJECT, offsetof(buffered, raw), PY_READONLY}, + {"_finalizing", T_BOOL, offsetof(buffered, finalizing), PY_READWRITE}, {NULL} }; @@ -2486,8 +2486,8 @@ static PyMethodDef bufferedwriter_methods[] = { }; static PyMemberDef bufferedwriter_members[] = { - {"raw", T_OBJECT, offsetof(buffered, raw), READONLY}, - {"_finalizing", T_BOOL, offsetof(buffered, finalizing), 0}, + {"raw", T_OBJECT, offsetof(buffered, raw), PY_READONLY}, + {"_finalizing", T_BOOL, offsetof(buffered, finalizing), PY_READWRITE}, {NULL} }; @@ -2657,8 +2657,8 @@ static PyMethodDef bufferedrandom_methods[] = { }; static PyMemberDef bufferedrandom_members[] = { - {"raw", T_OBJECT, offsetof(buffered, raw), READONLY}, - {"_finalizing", T_BOOL, offsetof(buffered, finalizing), 0}, + {"raw", T_OBJECT, offsetof(buffered, raw), PY_READONLY}, + {"_finalizing", T_BOOL, offsetof(buffered, finalizing), PY_READWRITE}, {NULL} }; diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c index c502c430134ef6c..5a9fbb2c6494624 100644 --- a/Modules/_io/fileio.c +++ b/Modules/_io/fileio.c @@ -1170,8 +1170,8 @@ static PyGetSetDef fileio_getsetlist[] = { }; static PyMemberDef fileio_members[] = { - {"_blksize", T_UINT, offsetof(fileio, blksize), 0}, - {"_finalizing", T_BOOL, offsetof(fileio, finalizing), 0}, + {"_blksize", T_UINT, offsetof(fileio, blksize), PY_READWRITE}, + {"_finalizing", T_BOOL, offsetof(fileio, finalizing), PY_READWRITE}, {NULL} }; diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c index 8c391659ecd8672..2bf6a05e37f6e1b 100644 --- a/Modules/_io/textio.c +++ b/Modules/_io/textio.c @@ -3143,11 +3143,11 @@ static PyMethodDef textiowrapper_methods[] = { }; static PyMemberDef textiowrapper_members[] = { - {"encoding", T_OBJECT, offsetof(textio, encoding), READONLY}, - {"buffer", T_OBJECT, offsetof(textio, buffer), READONLY}, - {"line_buffering", T_BOOL, offsetof(textio, line_buffering), READONLY}, - {"write_through", T_BOOL, offsetof(textio, write_through), READONLY}, - {"_finalizing", T_BOOL, offsetof(textio, finalizing), 0}, + {"encoding", T_OBJECT, offsetof(textio, encoding), PY_READONLY}, + {"buffer", T_OBJECT, offsetof(textio, buffer), PY_READONLY}, + {"line_buffering", T_BOOL, offsetof(textio, line_buffering), PY_READONLY}, + {"write_through", T_BOOL, offsetof(textio, write_through), PY_READONLY}, + {"_finalizing", T_BOOL, offsetof(textio, finalizing), PY_READWRITE}, {NULL} }; diff --git a/Modules/_io/winconsoleio.c b/Modules/_io/winconsoleio.c index 70a723ed746a75c..fdba1d42138d9df 100644 --- a/Modules/_io/winconsoleio.c +++ b/Modules/_io/winconsoleio.c @@ -1107,8 +1107,8 @@ static PyGetSetDef winconsoleio_getsetlist[] = { }; static PyMemberDef winconsoleio_members[] = { - {"_blksize", T_UINT, offsetof(winconsoleio, blksize), 0}, - {"_finalizing", T_BOOL, offsetof(winconsoleio, finalizing), 0}, + {"_blksize", T_UINT, offsetof(winconsoleio, blksize), PY_READWRITE}, + {"_finalizing", T_BOOL, offsetof(winconsoleio, finalizing), PY_READWRITE}, {NULL} }; diff --git a/Modules/_json.c b/Modules/_json.c index 94a7c0d2bf09e4a..3562dc5bc5c5735 100644 --- a/Modules/_json.c +++ b/Modules/_json.c @@ -35,12 +35,12 @@ typedef struct _PyScannerObject { } PyScannerObject; static PyMemberDef scanner_members[] = { - {"strict", T_BOOL, offsetof(PyScannerObject, strict), READONLY, "strict"}, - {"object_hook", T_OBJECT, offsetof(PyScannerObject, object_hook), READONLY, "object_hook"}, - {"object_pairs_hook", T_OBJECT, offsetof(PyScannerObject, object_pairs_hook), READONLY}, - {"parse_float", T_OBJECT, offsetof(PyScannerObject, parse_float), READONLY, "parse_float"}, - {"parse_int", T_OBJECT, offsetof(PyScannerObject, parse_int), READONLY, "parse_int"}, - {"parse_constant", T_OBJECT, offsetof(PyScannerObject, parse_constant), READONLY, "parse_constant"}, + {"strict", T_BOOL, offsetof(PyScannerObject, strict), PY_READONLY, "strict"}, + {"object_hook", T_OBJECT, offsetof(PyScannerObject, object_hook), PY_READONLY, "object_hook"}, + {"object_pairs_hook", T_OBJECT, offsetof(PyScannerObject, object_pairs_hook), PY_READONLY}, + {"parse_float", T_OBJECT, offsetof(PyScannerObject, parse_float), PY_READONLY, "parse_float"}, + {"parse_int", T_OBJECT, offsetof(PyScannerObject, parse_int), PY_READONLY, "parse_int"}, + {"parse_constant", T_OBJECT, offsetof(PyScannerObject, parse_constant), PY_READONLY, "parse_constant"}, {NULL} }; @@ -59,14 +59,14 @@ typedef struct _PyEncoderObject { } PyEncoderObject; static PyMemberDef encoder_members[] = { - {"markers", T_OBJECT, offsetof(PyEncoderObject, markers), READONLY, "markers"}, - {"default", T_OBJECT, offsetof(PyEncoderObject, defaultfn), READONLY, "default"}, - {"encoder", T_OBJECT, offsetof(PyEncoderObject, encoder), READONLY, "encoder"}, - {"indent", T_OBJECT, offsetof(PyEncoderObject, indent), READONLY, "indent"}, - {"key_separator", T_OBJECT, offsetof(PyEncoderObject, key_separator), READONLY, "key_separator"}, - {"item_separator", T_OBJECT, offsetof(PyEncoderObject, item_separator), READONLY, "item_separator"}, - {"sort_keys", T_BOOL, offsetof(PyEncoderObject, sort_keys), READONLY, "sort_keys"}, - {"skipkeys", T_BOOL, offsetof(PyEncoderObject, skipkeys), READONLY, "skipkeys"}, + {"markers", T_OBJECT, offsetof(PyEncoderObject, markers), PY_READONLY, "markers"}, + {"default", T_OBJECT, offsetof(PyEncoderObject, defaultfn), PY_READONLY, "default"}, + {"encoder", T_OBJECT, offsetof(PyEncoderObject, encoder), PY_READONLY, "encoder"}, + {"indent", T_OBJECT, offsetof(PyEncoderObject, indent), PY_READONLY, "indent"}, + {"key_separator", T_OBJECT, offsetof(PyEncoderObject, key_separator), PY_READONLY, "key_separator"}, + {"item_separator", T_OBJECT, offsetof(PyEncoderObject, item_separator), PY_READONLY, "item_separator"}, + {"sort_keys", T_BOOL, offsetof(PyEncoderObject, sort_keys), PY_READONLY, "sort_keys"}, + {"skipkeys", T_BOOL, offsetof(PyEncoderObject, skipkeys), PY_READONLY, "skipkeys"}, {NULL} }; diff --git a/Modules/_lzmamodule.c b/Modules/_lzmamodule.c index 18bc3dc296e00b5..033b1cd43492c98 100644 --- a/Modules/_lzmamodule.c +++ b/Modules/_lzmamodule.c @@ -1234,13 +1234,13 @@ PyDoc_STRVAR(Decompressor_unused_data_doc, "Data found after the end of the compressed stream."); static PyMemberDef Decompressor_members[] = { - {"check", T_INT, offsetof(Decompressor, check), READONLY, + {"check", T_INT, offsetof(Decompressor, check), PY_READONLY, Decompressor_check_doc}, - {"eof", T_BOOL, offsetof(Decompressor, eof), READONLY, + {"eof", T_BOOL, offsetof(Decompressor, eof), PY_READONLY, Decompressor_eof_doc}, - {"needs_input", T_BOOL, offsetof(Decompressor, needs_input), READONLY, + {"needs_input", T_BOOL, offsetof(Decompressor, needs_input), PY_READONLY, Decompressor_needs_input_doc}, - {"unused_data", T_OBJECT_EX, offsetof(Decompressor, unused_data), READONLY, + {"unused_data", T_OBJECT_EX, offsetof(Decompressor, unused_data), PY_READONLY, Decompressor_unused_data_doc}, {NULL} }; diff --git a/Modules/_multiprocessing/semaphore.c b/Modules/_multiprocessing/semaphore.c index cbcc64cb578fe50..c157126e9d0384f 100644 --- a/Modules/_multiprocessing/semaphore.c +++ b/Modules/_multiprocessing/semaphore.c @@ -612,13 +612,13 @@ static PyMethodDef semlock_methods[] = { */ static PyMemberDef semlock_members[] = { - {"handle", T_SEM_HANDLE, offsetof(SemLockObject, handle), READONLY, + {"handle", T_SEM_HANDLE, offsetof(SemLockObject, handle), PY_READONLY, ""}, - {"kind", T_INT, offsetof(SemLockObject, kind), READONLY, + {"kind", T_INT, offsetof(SemLockObject, kind), PY_READONLY, ""}, - {"maxvalue", T_INT, offsetof(SemLockObject, maxvalue), READONLY, + {"maxvalue", T_INT, offsetof(SemLockObject, maxvalue), PY_READONLY, ""}, - {"name", T_STRING, offsetof(SemLockObject, name), READONLY, + {"name", T_STRING, offsetof(SemLockObject, name), PY_READONLY, ""}, {NULL} }; diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c index e3340bf19f7bd36..f9c6baa5a2d99c8 100644 --- a/Modules/_sqlite/connection.c +++ b/Modules/_sqlite/connection.c @@ -1817,16 +1817,16 @@ static PyMethodDef connection_methods[] = { static struct PyMemberDef connection_members[] = { - {"Warning", T_OBJECT, offsetof(pysqlite_Connection, Warning), READONLY}, - {"Error", T_OBJECT, offsetof(pysqlite_Connection, Error), READONLY}, - {"InterfaceError", T_OBJECT, offsetof(pysqlite_Connection, InterfaceError), READONLY}, - {"DatabaseError", T_OBJECT, offsetof(pysqlite_Connection, DatabaseError), READONLY}, - {"DataError", T_OBJECT, offsetof(pysqlite_Connection, DataError), READONLY}, - {"OperationalError", T_OBJECT, offsetof(pysqlite_Connection, OperationalError), READONLY}, - {"IntegrityError", T_OBJECT, offsetof(pysqlite_Connection, IntegrityError), READONLY}, - {"InternalError", T_OBJECT, offsetof(pysqlite_Connection, InternalError), READONLY}, - {"ProgrammingError", T_OBJECT, offsetof(pysqlite_Connection, ProgrammingError), READONLY}, - {"NotSupportedError", T_OBJECT, offsetof(pysqlite_Connection, NotSupportedError), READONLY}, + {"Warning", T_OBJECT, offsetof(pysqlite_Connection, Warning), PY_READONLY}, + {"Error", T_OBJECT, offsetof(pysqlite_Connection, Error), PY_READONLY}, + {"InterfaceError", T_OBJECT, offsetof(pysqlite_Connection, InterfaceError), PY_READONLY}, + {"DatabaseError", T_OBJECT, offsetof(pysqlite_Connection, DatabaseError), PY_READONLY}, + {"DataError", T_OBJECT, offsetof(pysqlite_Connection, DataError), PY_READONLY}, + {"OperationalError", T_OBJECT, offsetof(pysqlite_Connection, OperationalError), PY_READONLY}, + {"IntegrityError", T_OBJECT, offsetof(pysqlite_Connection, IntegrityError), PY_READONLY}, + {"InternalError", T_OBJECT, offsetof(pysqlite_Connection, InternalError), PY_READONLY}, + {"ProgrammingError", T_OBJECT, offsetof(pysqlite_Connection, ProgrammingError), PY_READONLY}, + {"NotSupportedError", T_OBJECT, offsetof(pysqlite_Connection, NotSupportedError), PY_READONLY}, {"row_factory", T_OBJECT, offsetof(pysqlite_Connection, row_factory)}, {"text_factory", T_OBJECT, offsetof(pysqlite_Connection, text_factory)}, {NULL} diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c index 2bc19311a81d219..82e2232cac18323 100644 --- a/Modules/_sqlite/cursor.c +++ b/Modules/_sqlite/cursor.c @@ -904,12 +904,12 @@ static PyMethodDef cursor_methods[] = { static struct PyMemberDef cursor_members[] = { - {"connection", T_OBJECT, offsetof(pysqlite_Cursor, connection), READONLY}, - {"description", T_OBJECT, offsetof(pysqlite_Cursor, description), READONLY}, - {"arraysize", T_INT, offsetof(pysqlite_Cursor, arraysize), 0}, - {"lastrowid", T_OBJECT, offsetof(pysqlite_Cursor, lastrowid), READONLY}, - {"rowcount", T_LONG, offsetof(pysqlite_Cursor, rowcount), READONLY}, - {"row_factory", T_OBJECT, offsetof(pysqlite_Cursor, row_factory), 0}, + {"connection", T_OBJECT, offsetof(pysqlite_Cursor, connection), PY_READONLY}, + {"description", T_OBJECT, offsetof(pysqlite_Cursor, description), PY_READONLY}, + {"arraysize", T_INT, offsetof(pysqlite_Cursor, arraysize), PY_READWRITE}, + {"lastrowid", T_OBJECT, offsetof(pysqlite_Cursor, lastrowid), PY_READONLY}, + {"rowcount", T_LONG, offsetof(pysqlite_Cursor, rowcount), PY_READONLY}, + {"row_factory", T_OBJECT, offsetof(pysqlite_Cursor, row_factory), PY_READWRITE}, {NULL} }; diff --git a/Modules/_sre.c b/Modules/_sre.c index 014cc546e345d9a..22bfe115fb7baff 100644 --- a/Modules/_sre.c +++ b/Modules/_sre.c @@ -2580,11 +2580,11 @@ static PyGetSetDef pattern_getset[] = { #define PAT_OFF(x) offsetof(PatternObject, x) static PyMemberDef pattern_members[] = { - {"pattern", T_OBJECT, PAT_OFF(pattern), READONLY, + {"pattern", T_OBJECT, PAT_OFF(pattern), PY_READONLY, "The pattern string from which the RE object was compiled."}, - {"flags", T_INT, PAT_OFF(flags), READONLY, + {"flags", T_INT, PAT_OFF(flags), PY_READONLY, "The regex matching flags."}, - {"groups", T_PYSSIZET, PAT_OFF(groups), READONLY, + {"groups", T_PYSSIZET, PAT_OFF(groups), PY_READONLY, "The number of capturing groups in the pattern."}, {NULL} /* Sentinel */ }; @@ -2653,13 +2653,13 @@ static PyGetSetDef match_getset[] = { #define MATCH_OFF(x) offsetof(MatchObject, x) static PyMemberDef match_members[] = { - {"string", T_OBJECT, MATCH_OFF(string), READONLY, + {"string", T_OBJECT, MATCH_OFF(string), PY_READONLY, "The string passed to match() or search()."}, - {"re", T_OBJECT, MATCH_OFF(pattern), READONLY, + {"re", T_OBJECT, MATCH_OFF(pattern), PY_READONLY, "The regular expression object."}, - {"pos", T_PYSSIZET, MATCH_OFF(pos), READONLY, + {"pos", T_PYSSIZET, MATCH_OFF(pos), PY_READONLY, "The index into the string at which the RE engine started looking for a match."}, - {"endpos", T_PYSSIZET, MATCH_OFF(endpos), READONLY, + {"endpos", T_PYSSIZET, MATCH_OFF(endpos), PY_READONLY, "The index into the string beyond which the RE engine will not go."}, {NULL} }; @@ -2707,7 +2707,7 @@ static PyMethodDef scanner_methods[] = { #define SCAN_OFF(x) offsetof(ScannerObject, x) static PyMemberDef scanner_members[] = { - {"pattern", T_OBJECT, SCAN_OFF(pattern), READONLY}, + {"pattern", T_OBJECT, SCAN_OFF(pattern), PY_READONLY}, {NULL} /* Sentinel */ }; diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 350ef771630eab0..a2e7fde622ff6d4 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -4976,22 +4976,24 @@ typedef struct { all_structmembers structmembers; } test_structmembers; +#define OFF(field) offsetof(test_structmembers, structmembers.field) + static struct PyMemberDef test_members[] = { - {"T_BOOL", T_BOOL, offsetof(test_structmembers, structmembers.bool_member), 0, NULL}, - {"T_BYTE", T_BYTE, offsetof(test_structmembers, structmembers.byte_member), 0, NULL}, - {"T_UBYTE", T_UBYTE, offsetof(test_structmembers, structmembers.ubyte_member), 0, NULL}, - {"T_SHORT", T_SHORT, offsetof(test_structmembers, structmembers.short_member), 0, NULL}, - {"T_USHORT", T_USHORT, offsetof(test_structmembers, structmembers.ushort_member), 0, NULL}, - {"T_INT", T_INT, offsetof(test_structmembers, structmembers.int_member), 0, NULL}, - {"T_UINT", T_UINT, offsetof(test_structmembers, structmembers.uint_member), 0, NULL}, - {"T_LONG", T_LONG, offsetof(test_structmembers, structmembers.long_member), 0, NULL}, - {"T_ULONG", T_ULONG, offsetof(test_structmembers, structmembers.ulong_member), 0, NULL}, - {"T_PYSSIZET", T_PYSSIZET, offsetof(test_structmembers, structmembers.pyssizet_member), 0, NULL}, - {"T_FLOAT", T_FLOAT, offsetof(test_structmembers, structmembers.float_member), 0, NULL}, - {"T_DOUBLE", T_DOUBLE, offsetof(test_structmembers, structmembers.double_member), 0, NULL}, - {"T_STRING_INPLACE", T_STRING_INPLACE, offsetof(test_structmembers, structmembers.inplace_member), 0, NULL}, - {"T_LONGLONG", T_LONGLONG, offsetof(test_structmembers, structmembers.longlong_member), 0, NULL}, - {"T_ULONGLONG", T_ULONGLONG, offsetof(test_structmembers, structmembers.ulonglong_member), 0, NULL}, + {"T_BOOL", T_BOOL, OFF(bool_member), PY_READWRITE, NULL}, + {"T_BYTE", T_BYTE, OFF(byte_member), PY_READWRITE, NULL}, + {"T_UBYTE", T_UBYTE, OFF(ubyte_member), PY_READWRITE, NULL}, + {"T_SHORT", T_SHORT, OFF(short_member), PY_READWRITE, NULL}, + {"T_USHORT", T_USHORT, OFF(ushort_member), PY_READWRITE, NULL}, + {"T_INT", T_INT, OFF(int_member), PY_READWRITE, NULL}, + {"T_UINT", T_UINT, OFF(uint_member), PY_READWRITE, NULL}, + {"T_LONG", T_LONG, OFF(long_member), PY_READWRITE, NULL}, + {"T_ULONG", T_ULONG, OFF(ulong_member), PY_READWRITE, NULL}, + {"T_PYSSIZET", T_PYSSIZET, OFF(pyssizet_member), PY_READWRITE, NULL}, + {"T_FLOAT", T_FLOAT, OFF(float_member), PY_READWRITE, NULL}, + {"T_DOUBLE", T_DOUBLE, OFF(double_member), PY_READWRITE, NULL}, + {"T_STRING_INPLACE", T_STRING_INPLACE, OFF(inplace_member), PY_READWRITE, NULL}, + {"T_LONGLONG", T_LONGLONG, OFF(longlong_member), PY_READWRITE, NULL}, + {"T_ULONGLONG", T_ULONGLONG, OFF(ulonglong_member), PY_READWRITE, NULL}, {NULL} }; diff --git a/Modules/_winapi.c b/Modules/_winapi.c index e7b221d888ef8d8..ed78791079bd008 100644 --- a/Modules/_winapi.c +++ b/Modules/_winapi.c @@ -300,7 +300,7 @@ static PyMethodDef overlapped_methods[] = { static PyMemberDef overlapped_members[] = { {"event", T_HANDLE, offsetof(OverlappedObject, overlapped) + offsetof(OVERLAPPED, hEvent), - READONLY, "overlapped event handle"}, + PY_READONLY, "overlapped event handle"}, {NULL} }; diff --git a/Modules/cjkcodecs/multibytecodec.c b/Modules/cjkcodecs/multibytecodec.c index f266e5f33a60b18..e046e3ad75fc563 100644 --- a/Modules/cjkcodecs/multibytecodec.c +++ b/Modules/cjkcodecs/multibytecodec.c @@ -1655,7 +1655,7 @@ static struct PyMethodDef mbstreamreader_methods[] = { static PyMemberDef mbstreamreader_members[] = { {"stream", T_OBJECT, offsetof(MultibyteStreamReaderObject, stream), - READONLY, NULL}, + PY_READONLY, NULL}, {NULL,} }; @@ -1969,7 +1969,7 @@ static struct PyMethodDef mbstreamwriter_methods[] = { static PyMemberDef mbstreamwriter_members[] = { {"stream", T_OBJECT, offsetof(MultibyteStreamWriterObject, stream), - READONLY, NULL}, + PY_READONLY, NULL}, {NULL,} }; diff --git a/Modules/ossaudiodev.c b/Modules/ossaudiodev.c index 2222148c85161c6..51683a32a711977 100644 --- a/Modules/ossaudiodev.c +++ b/Modules/ossaudiodev.c @@ -922,7 +922,7 @@ static PyMethodDef oss_mixer_methods[] = { }; static PyMemberDef oss_members[] = { - {"name", T_STRING, offsetof(oss_audio_t, devicename), READONLY, NULL}, + {"name", T_STRING, offsetof(oss_audio_t, devicename), PY_READONLY, NULL}, {NULL} }; diff --git a/Modules/overlapped.c b/Modules/overlapped.c index e5a209bf7582977..265a42179cf6050 100644 --- a/Modules/overlapped.c +++ b/Modules/overlapped.c @@ -1405,10 +1405,10 @@ static PyMethodDef Overlapped_methods[] = { static PyMemberDef Overlapped_members[] = { {"error", T_ULONG, offsetof(OverlappedObject, error), - READONLY, "Error from last operation"}, + PY_READONLY, "Error from last operation"}, {"event", T_HANDLE, offsetof(OverlappedObject, overlapped) + offsetof(OVERLAPPED, hEvent), - READONLY, "Overlapped event handle"}, + PY_READONLY, "Overlapped event handle"}, {NULL} }; diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 3f760183575aaca..879bdbc8e132b00 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -12418,9 +12418,9 @@ os_DirEntry___fspath___impl(DirEntry *self) } static PyMemberDef DirEntry_members[] = { - {"name", T_OBJECT_EX, offsetof(DirEntry, name), READONLY, + {"name", T_OBJECT_EX, offsetof(DirEntry, name), PY_READONLY, "the entry's base filename, relative to scandir() \"path\" argument"}, - {"path", T_OBJECT_EX, offsetof(DirEntry, path), READONLY, + {"path", T_OBJECT_EX, offsetof(DirEntry, path), PY_READONLY, "the entry's full path name; equivalent to os.path.join(scandir_path, entry.name)"}, {NULL} }; diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c index 2e8be3706db9141..ad5416f421d6202 100644 --- a/Modules/pyexpat.c +++ b/Modules/pyexpat.c @@ -1412,7 +1412,7 @@ xmlparse_specified_attributes_setter(xmlparseobject *self, PyObject *v, void *cl } static PyMemberDef xmlparse_members[] = { - {"intern", T_OBJECT, offsetof(xmlparseobject, intern), READONLY, NULL}, + {"intern", T_OBJECT, offsetof(xmlparseobject, intern), PY_READONLY, NULL}, {NULL} }; diff --git a/Modules/sha256module.c b/Modules/sha256module.c index 20b5f02f5481b1e..b4d9773b7fbaef3 100644 --- a/Modules/sha256module.c +++ b/Modules/sha256module.c @@ -522,7 +522,7 @@ static PyGetSetDef SHA_getseters[] = { }; static PyMemberDef SHA_members[] = { - {"digest_size", T_INT, offsetof(SHAobject, digestsize), READONLY, NULL}, + {"digest_size", T_INT, offsetof(SHAobject, digestsize), PY_READONLY, NULL}, {NULL} /* Sentinel */ }; diff --git a/Modules/sha512module.c b/Modules/sha512module.c index e070e4389f4cfd6..dc7b8382b533907 100644 --- a/Modules/sha512module.c +++ b/Modules/sha512module.c @@ -587,7 +587,7 @@ static PyGetSetDef SHA_getseters[] = { }; static PyMemberDef SHA_members[] = { - {"digest_size", T_INT, offsetof(SHAobject, digestsize), READONLY, NULL}, + {"digest_size", T_INT, offsetof(SHAobject, digestsize), PY_READONLY, NULL}, {NULL} /* Sentinel */ }; diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 1120f6b51325a0b..40ef34ffe4675a8 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -4861,9 +4861,9 @@ static PyMethodDef sock_methods[] = { /* SockObject members */ static PyMemberDef sock_memberlist[] = { - {"family", T_INT, offsetof(PySocketSockObject, sock_family), READONLY, "the socket family"}, - {"type", T_INT, offsetof(PySocketSockObject, sock_type), READONLY, "the socket type"}, - {"proto", T_INT, offsetof(PySocketSockObject, sock_proto), READONLY, "the socket protocol"}, + {"family", T_INT, offsetof(PySocketSockObject, sock_family), PY_READONLY, "the socket family"}, + {"type", T_INT, offsetof(PySocketSockObject, sock_type), PY_READONLY, "the socket type"}, + {"proto", T_INT, offsetof(PySocketSockObject, sock_proto), PY_READONLY, "the socket protocol"}, {0}, }; diff --git a/Modules/unicodedata.c b/Modules/unicodedata.c index 9ceab1b3db4f788..1e53d305e35e1c6 100644 --- a/Modules/unicodedata.c +++ b/Modules/unicodedata.c @@ -84,7 +84,7 @@ typedef struct previous_version { #define get_old_record(self, v) ((((PreviousDBVersion*)self)->getrecord)(v)) static PyMemberDef DB_members[] = { - {"unidata_version", T_STRING, offsetof(PreviousDBVersion, name), READONLY}, + {"unidata_version", T_STRING, offsetof(PreviousDBVersion, name), PY_READONLY}, {NULL} }; diff --git a/Modules/xxsubtype.c b/Modules/xxsubtype.c index bacbdf15361814b..e51dad912e3badb 100644 --- a/Modules/xxsubtype.c +++ b/Modules/xxsubtype.c @@ -186,7 +186,7 @@ spamdict_init(spamdictobject *self, PyObject *args, PyObject *kwds) } static PyMemberDef spamdict_members[] = { - {"state", T_INT, offsetof(spamdictobject, state), READONLY, + {"state", T_INT, offsetof(spamdictobject, state), PY_READONLY, PyDoc_STR("an int variable for demonstration purposes")}, {0} }; diff --git a/Modules/zlibmodule.c b/Modules/zlibmodule.c index 5778dbb715f92c4..3e075ade3f0376d 100644 --- a/Modules/zlibmodule.c +++ b/Modules/zlibmodule.c @@ -1211,9 +1211,9 @@ static PyMethodDef Decomp_methods[] = #define COMP_OFF(x) offsetof(compobject, x) static PyMemberDef Decomp_members[] = { - {"unused_data", T_OBJECT, COMP_OFF(unused_data), READONLY}, - {"unconsumed_tail", T_OBJECT, COMP_OFF(unconsumed_tail), READONLY}, - {"eof", T_BOOL, COMP_OFF(eof), READONLY}, + {"unused_data", T_OBJECT, COMP_OFF(unused_data), PY_READONLY}, + {"unconsumed_tail", T_OBJECT, COMP_OFF(unconsumed_tail), PY_READONLY}, + {"eof", T_BOOL, COMP_OFF(eof), PY_READONLY}, {NULL}, }; diff --git a/Objects/classobject.c b/Objects/classobject.c index 1ee897847fb03e3..3c8cc6819309aaa 100644 --- a/Objects/classobject.c +++ b/Objects/classobject.c @@ -101,9 +101,9 @@ static PyMethodDef method_methods[] = { #define MO_OFF(x) offsetof(PyMethodObject, x) static PyMemberDef method_memberlist[] = { - {"__func__", T_OBJECT, MO_OFF(im_func), READONLY|RESTRICTED, + {"__func__", T_OBJECT, MO_OFF(im_func), PY_READONLY|PY_RESTRICTED, "the function (or other callable) implementing a method"}, - {"__self__", T_OBJECT, MO_OFF(im_self), READONLY|RESTRICTED, + {"__self__", T_OBJECT, MO_OFF(im_self), PY_READONLY|PY_RESTRICTED, "the instance to which a method is bound"}, {NULL} /* Sentinel */ }; @@ -405,7 +405,7 @@ PyInstanceMethod_Function(PyObject *im) #define IMO_OFF(x) offsetof(PyInstanceMethodObject, x) static PyMemberDef instancemethod_memberlist[] = { - {"__func__", T_OBJECT, IMO_OFF(func), READONLY|RESTRICTED, + {"__func__", T_OBJECT, IMO_OFF(func), PY_READONLY|PY_RESTRICTED, "the function (or other callable) implementing a method"}, {NULL} /* Sentinel */ }; diff --git a/Objects/codeobject.c b/Objects/codeobject.c index 09182d61c24474f..d86f920d2b037e3 100644 --- a/Objects/codeobject.c +++ b/Objects/codeobject.c @@ -274,21 +274,21 @@ PyCode_NewEmpty(const char *filename, const char *funcname, int firstlineno) #define OFF(x) offsetof(PyCodeObject, x) static PyMemberDef code_memberlist[] = { - {"co_argcount", T_INT, OFF(co_argcount), READONLY}, - {"co_kwonlyargcount", T_INT, OFF(co_kwonlyargcount), READONLY}, - {"co_nlocals", T_INT, OFF(co_nlocals), READONLY}, - {"co_stacksize",T_INT, OFF(co_stacksize), READONLY}, - {"co_flags", T_INT, OFF(co_flags), READONLY}, - {"co_code", T_OBJECT, OFF(co_code), READONLY}, - {"co_consts", T_OBJECT, OFF(co_consts), READONLY}, - {"co_names", T_OBJECT, OFF(co_names), READONLY}, - {"co_varnames", T_OBJECT, OFF(co_varnames), READONLY}, - {"co_freevars", T_OBJECT, OFF(co_freevars), READONLY}, - {"co_cellvars", T_OBJECT, OFF(co_cellvars), READONLY}, - {"co_filename", T_OBJECT, OFF(co_filename), READONLY}, - {"co_name", T_OBJECT, OFF(co_name), READONLY}, - {"co_firstlineno", T_INT, OFF(co_firstlineno), READONLY}, - {"co_lnotab", T_OBJECT, OFF(co_lnotab), READONLY}, + {"co_argcount", T_INT, OFF(co_argcount), PY_READONLY}, + {"co_kwonlyargcount", T_INT, OFF(co_kwonlyargcount), PY_READONLY}, + {"co_nlocals", T_INT, OFF(co_nlocals), PY_READONLY}, + {"co_stacksize",T_INT, OFF(co_stacksize), PY_READONLY}, + {"co_flags", T_INT, OFF(co_flags), PY_READONLY}, + {"co_code", T_OBJECT, OFF(co_code), PY_READONLY}, + {"co_consts", T_OBJECT, OFF(co_consts), PY_READONLY}, + {"co_names", T_OBJECT, OFF(co_names), PY_READONLY}, + {"co_varnames", T_OBJECT, OFF(co_varnames), PY_READONLY}, + {"co_freevars", T_OBJECT, OFF(co_freevars), PY_READONLY}, + {"co_cellvars", T_OBJECT, OFF(co_cellvars), PY_READONLY}, + {"co_filename", T_OBJECT, OFF(co_filename), PY_READONLY}, + {"co_name", T_OBJECT, OFF(co_name), PY_READONLY}, + {"co_firstlineno", T_INT, OFF(co_firstlineno), PY_READONLY}, + {"co_lnotab", T_OBJECT, OFF(co_lnotab), PY_READONLY}, {NULL} /* Sentinel */ }; diff --git a/Objects/complexobject.c b/Objects/complexobject.c index 6e3d47b62d19374..f306ad06ffea01f 100644 --- a/Objects/complexobject.c +++ b/Objects/complexobject.c @@ -772,9 +772,9 @@ static PyMethodDef complex_methods[] = { }; static PyMemberDef complex_members[] = { - {"real", T_DOUBLE, offsetof(PyComplexObject, cval.real), READONLY, + {"real", T_DOUBLE, offsetof(PyComplexObject, cval.real), PY_READONLY, "the real part of a complex number"}, - {"imag", T_DOUBLE, offsetof(PyComplexObject, cval.imag), READONLY, + {"imag", T_DOUBLE, offsetof(PyComplexObject, cval.imag), PY_READONLY, "the imaginary part of a complex number"}, {0}, }; diff --git a/Objects/descrobject.c b/Objects/descrobject.c index 22546a563a51c08..ce353afc49852f6 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -463,8 +463,8 @@ static PyMethodDef descr_methods[] = { }; static PyMemberDef descr_members[] = { - {"__objclass__", T_OBJECT, offsetof(PyDescrObject, d_type), READONLY}, - {"__name__", T_OBJECT, offsetof(PyDescrObject, d_name), READONLY}, + {"__objclass__", T_OBJECT, offsetof(PyDescrObject, d_type), PY_READONLY}, + {"__name__", T_OBJECT, offsetof(PyDescrObject, d_name), PY_READONLY}, {0} }; @@ -1093,7 +1093,7 @@ static PyMethodDef wrapper_methods[] = { }; static PyMemberDef wrapper_members[] = { - {"__self__", T_OBJECT, offsetof(wrapperobject, self), READONLY}, + {"__self__", T_OBJECT, offsetof(wrapperobject, self), PY_READONLY}, {0} }; @@ -1262,10 +1262,10 @@ static PyObject * property_copy(PyObject *, PyObject *, PyObject *, PyObject *); static PyMemberDef property_members[] = { - {"fget", T_OBJECT, offsetof(propertyobject, prop_get), READONLY}, - {"fset", T_OBJECT, offsetof(propertyobject, prop_set), READONLY}, - {"fdel", T_OBJECT, offsetof(propertyobject, prop_del), READONLY}, - {"__doc__", T_OBJECT, offsetof(propertyobject, prop_doc), 0}, + {"fget", T_OBJECT, offsetof(propertyobject, prop_get), PY_READONLY}, + {"fset", T_OBJECT, offsetof(propertyobject, prop_set), PY_READONLY}, + {"fdel", T_OBJECT, offsetof(propertyobject, prop_del), PY_READONLY}, + {"__doc__", T_OBJECT, offsetof(propertyobject, prop_doc), PY_READWRITE}, {0} }; diff --git a/Objects/exceptions.c b/Objects/exceptions.c index ad2a54a2b6b05b9..fe2557db3694272 100644 --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -486,7 +486,7 @@ SimpleExtendsException(PyExc_Exception, StopAsyncIteration, */ static PyMemberDef StopIteration_members[] = { - {"value", T_OBJECT, offsetof(PyStopIterationObject, value), 0, + {"value", T_OBJECT, offsetof(PyStopIterationObject, value), PY_READWRITE, PyDoc_STR("generator return value")}, {NULL} /* Sentinel */ }; @@ -599,7 +599,7 @@ SystemExit_traverse(PySystemExitObject *self, visitproc visit, void *arg) } static PyMemberDef SystemExit_members[] = { - {"code", T_OBJECT, offsetof(PySystemExitObject, code), 0, + {"code", T_OBJECT, offsetof(PySystemExitObject, code), PY_READWRITE, PyDoc_STR("exception code")}, {NULL} /* Sentinel */ }; @@ -742,11 +742,11 @@ ImportError_reduce(PyImportErrorObject *self, PyObject *Py_UNUSED(ignored)) } static PyMemberDef ImportError_members[] = { - {"msg", T_OBJECT, offsetof(PyImportErrorObject, msg), 0, + {"msg", T_OBJECT, offsetof(PyImportErrorObject, msg), PY_READWRITE, PyDoc_STR("exception message")}, - {"name", T_OBJECT, offsetof(PyImportErrorObject, name), 0, + {"name", T_OBJECT, offsetof(PyImportErrorObject, name), PY_READWRITE, PyDoc_STR("module name")}, - {"path", T_OBJECT, offsetof(PyImportErrorObject, path), 0, + {"path", T_OBJECT, offsetof(PyImportErrorObject, path), PY_READWRITE, PyDoc_STR("module path")}, {NULL} /* Sentinel */ }; @@ -1213,16 +1213,16 @@ OSError_written_set(PyOSErrorObject *self, PyObject *arg, void *context) } static PyMemberDef OSError_members[] = { - {"errno", T_OBJECT, offsetof(PyOSErrorObject, myerrno), 0, + {"errno", T_OBJECT, offsetof(PyOSErrorObject, myerrno), PY_READWRITE, PyDoc_STR("POSIX exception code")}, - {"strerror", T_OBJECT, offsetof(PyOSErrorObject, strerror), 0, + {"strerror", T_OBJECT, offsetof(PyOSErrorObject, strerror), PY_READWRITE, PyDoc_STR("exception strerror")}, - {"filename", T_OBJECT, offsetof(PyOSErrorObject, filename), 0, + {"filename", T_OBJECT, offsetof(PyOSErrorObject, filename), PY_READWRITE, PyDoc_STR("exception filename")}, - {"filename2", T_OBJECT, offsetof(PyOSErrorObject, filename2), 0, + {"filename2", T_OBJECT, offsetof(PyOSErrorObject, filename2), PY_READWRITE, PyDoc_STR("second exception filename")}, #ifdef MS_WINDOWS - {"winerror", T_OBJECT, offsetof(PyOSErrorObject, winerror), 0, + {"winerror", T_OBJECT, offsetof(PyOSErrorObject, winerror), PY_READWRITE, PyDoc_STR("Win32 exception code")}, #endif {NULL} /* Sentinel */ @@ -1492,18 +1492,18 @@ SyntaxError_str(PySyntaxErrorObject *self) } static PyMemberDef SyntaxError_members[] = { - {"msg", T_OBJECT, offsetof(PySyntaxErrorObject, msg), 0, + {"msg", T_OBJECT, offsetof(PySyntaxErrorObject, msg), PY_READWRITE, PyDoc_STR("exception msg")}, - {"filename", T_OBJECT, offsetof(PySyntaxErrorObject, filename), 0, + {"filename", T_OBJECT, offsetof(PySyntaxErrorObject, filename), PY_READWRITE, PyDoc_STR("exception filename")}, - {"lineno", T_OBJECT, offsetof(PySyntaxErrorObject, lineno), 0, + {"lineno", T_OBJECT, offsetof(PySyntaxErrorObject, lineno), PY_READWRITE, PyDoc_STR("exception lineno")}, - {"offset", T_OBJECT, offsetof(PySyntaxErrorObject, offset), 0, + {"offset", T_OBJECT, offsetof(PySyntaxErrorObject, offset), PY_READWRITE, PyDoc_STR("exception offset")}, - {"text", T_OBJECT, offsetof(PySyntaxErrorObject, text), 0, + {"text", T_OBJECT, offsetof(PySyntaxErrorObject, text), PY_READWRITE, PyDoc_STR("exception text")}, {"print_file_and_line", T_OBJECT, - offsetof(PySyntaxErrorObject, print_file_and_line), 0, + offsetof(PySyntaxErrorObject, print_file_and_line), PY_READWRITE, PyDoc_STR("exception print_file_and_line")}, {NULL} /* Sentinel */ }; @@ -1866,15 +1866,15 @@ UnicodeError_traverse(PyUnicodeErrorObject *self, visitproc visit, void *arg) } static PyMemberDef UnicodeError_members[] = { - {"encoding", T_OBJECT, offsetof(PyUnicodeErrorObject, encoding), 0, + {"encoding", T_OBJECT, offsetof(PyUnicodeErrorObject, encoding), PY_READWRITE, PyDoc_STR("exception encoding")}, - {"object", T_OBJECT, offsetof(PyUnicodeErrorObject, object), 0, + {"object", T_OBJECT, offsetof(PyUnicodeErrorObject, object), PY_READWRITE, PyDoc_STR("exception object")}, - {"start", T_PYSSIZET, offsetof(PyUnicodeErrorObject, start), 0, + {"start", T_PYSSIZET, offsetof(PyUnicodeErrorObject, start), PY_READWRITE, PyDoc_STR("exception start")}, - {"end", T_PYSSIZET, offsetof(PyUnicodeErrorObject, end), 0, + {"end", T_PYSSIZET, offsetof(PyUnicodeErrorObject, end), PY_READWRITE, PyDoc_STR("exception end")}, - {"reason", T_OBJECT, offsetof(PyUnicodeErrorObject, reason), 0, + {"reason", T_OBJECT, offsetof(PyUnicodeErrorObject, reason), PY_READWRITE, PyDoc_STR("exception reason")}, {NULL} /* Sentinel */ }; diff --git a/Objects/frameobject.c b/Objects/frameobject.c index b668465df3da19e..37f3d6364d6c749 100644 --- a/Objects/frameobject.c +++ b/Objects/frameobject.c @@ -12,13 +12,13 @@ #define OFF(x) offsetof(PyFrameObject, x) static PyMemberDef frame_memberlist[] = { - {"f_back", T_OBJECT, OFF(f_back), READONLY}, - {"f_code", T_OBJECT, OFF(f_code), READONLY}, - {"f_builtins", T_OBJECT, OFF(f_builtins), READONLY}, - {"f_globals", T_OBJECT, OFF(f_globals), READONLY}, - {"f_lasti", T_INT, OFF(f_lasti), READONLY}, - {"f_trace_lines", T_BOOL, OFF(f_trace_lines), 0}, - {"f_trace_opcodes", T_BOOL, OFF(f_trace_opcodes), 0}, + {"f_back", T_OBJECT, OFF(f_back), PY_READONLY}, + {"f_code", T_OBJECT, OFF(f_code), PY_READONLY}, + {"f_builtins", T_OBJECT, OFF(f_builtins), PY_READONLY}, + {"f_globals", T_OBJECT, OFF(f_globals), PY_READONLY}, + {"f_lasti", T_INT, OFF(f_lasti), PY_READONLY}, + {"f_trace_lines", T_BOOL, OFF(f_trace_lines), PY_READWRITE}, + {"f_trace_opcodes", T_BOOL, OFF(f_trace_opcodes), PY_READWRITE}, {NULL} /* Sentinel */ }; diff --git a/Objects/funcobject.c b/Objects/funcobject.c index e8e2d2e15ccabf2..341953cf1e2d90d 100644 --- a/Objects/funcobject.c +++ b/Objects/funcobject.c @@ -239,10 +239,10 @@ PyFunction_SetAnnotations(PyObject *op, PyObject *annotations) static PyMemberDef func_memberlist[] = { {"__closure__", T_OBJECT, OFF(func_closure), - RESTRICTED|READONLY}, + PY_RESTRICTED|PY_READONLY}, {"__doc__", T_OBJECT, OFF(func_doc), PY_WRITE_RESTRICTED}, {"__globals__", T_OBJECT, OFF(func_globals), - RESTRICTED|READONLY}, + PY_RESTRICTED|PY_READONLY}, {"__module__", T_OBJECT, OFF(func_module), PY_WRITE_RESTRICTED}, {NULL} /* Sentinel */ }; @@ -728,7 +728,7 @@ cm_init(PyObject *self, PyObject *args, PyObject *kwds) } static PyMemberDef cm_memberlist[] = { - {"__func__", T_OBJECT, offsetof(classmethod, cm_callable), READONLY}, + {"__func__", T_OBJECT, offsetof(classmethod, cm_callable), PY_READONLY}, {NULL} /* Sentinel */ }; @@ -910,7 +910,7 @@ sm_init(PyObject *self, PyObject *args, PyObject *kwds) } static PyMemberDef sm_memberlist[] = { - {"__func__", T_OBJECT, offsetof(staticmethod, sm_callable), READONLY}, + {"__func__", T_OBJECT, offsetof(staticmethod, sm_callable), PY_READONLY}, {NULL} /* Sentinel */ }; diff --git a/Objects/genobject.c b/Objects/genobject.c index e2def38af541a55..f407c9b63e28a01 100644 --- a/Objects/genobject.c +++ b/Objects/genobject.c @@ -708,9 +708,9 @@ static PyGetSetDef gen_getsetlist[] = { }; static PyMemberDef gen_memberlist[] = { - {"gi_frame", T_OBJECT, offsetof(PyGenObject, gi_frame), READONLY}, - {"gi_running", T_BOOL, offsetof(PyGenObject, gi_running), READONLY}, - {"gi_code", T_OBJECT, offsetof(PyGenObject, gi_code), READONLY}, + {"gi_frame", T_OBJECT, offsetof(PyGenObject, gi_frame), PY_READONLY}, + {"gi_running", T_BOOL, offsetof(PyGenObject, gi_running), PY_READONLY}, + {"gi_code", T_OBJECT, offsetof(PyGenObject, gi_code), PY_READONLY}, {NULL} /* Sentinel */ }; @@ -945,10 +945,10 @@ static PyGetSetDef coro_getsetlist[] = { }; static PyMemberDef coro_memberlist[] = { - {"cr_frame", T_OBJECT, offsetof(PyCoroObject, cr_frame), READONLY}, - {"cr_running", T_BOOL, offsetof(PyCoroObject, cr_running), READONLY}, - {"cr_code", T_OBJECT, offsetof(PyCoroObject, cr_code), READONLY}, - {"cr_origin", T_OBJECT, offsetof(PyCoroObject, cr_origin), READONLY}, + {"cr_frame", T_OBJECT, offsetof(PyCoroObject, cr_frame), PY_READONLY}, + {"cr_running", T_BOOL, offsetof(PyCoroObject, cr_running), PY_READONLY}, + {"cr_code", T_OBJECT, offsetof(PyCoroObject, cr_code), PY_READONLY}, + {"cr_origin", T_OBJECT, offsetof(PyCoroObject, cr_origin), PY_READONLY}, {NULL} /* Sentinel */ }; @@ -1343,9 +1343,9 @@ static PyGetSetDef async_gen_getsetlist[] = { }; static PyMemberDef async_gen_memberlist[] = { - {"ag_frame", T_OBJECT, offsetof(PyAsyncGenObject, ag_frame), READONLY}, - {"ag_running", T_BOOL, offsetof(PyAsyncGenObject, ag_running), READONLY}, - {"ag_code", T_OBJECT, offsetof(PyAsyncGenObject, ag_code), READONLY}, + {"ag_frame", T_OBJECT, offsetof(PyAsyncGenObject, ag_frame), PY_READONLY}, + {"ag_running", T_BOOL, offsetof(PyAsyncGenObject, ag_running), PY_READONLY}, + {"ag_code", T_OBJECT, offsetof(PyAsyncGenObject, ag_code), PY_READONLY}, {NULL} /* Sentinel */ }; diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c index 9d6533257bb1214..466fa9462da3fcb 100644 --- a/Objects/moduleobject.c +++ b/Objects/moduleobject.c @@ -17,7 +17,7 @@ typedef struct { } PyModuleObject; static PyMemberDef module_members[] = { - {"__dict__", T_OBJECT, offsetof(PyModuleObject, md_dict), READONLY}, + {"__dict__", T_OBJECT, offsetof(PyModuleObject, md_dict), PY_READONLY}, {0} }; diff --git a/Objects/namespaceobject.c b/Objects/namespaceobject.c index aba3ff7b05e984a..480cba0811d72bf 100644 --- a/Objects/namespaceobject.c +++ b/Objects/namespaceobject.c @@ -11,7 +11,7 @@ typedef struct { static PyMemberDef namespace_members[] = { - {"__dict__", T_OBJECT, offsetof(_PyNamespaceObject, ns_dict), READONLY}, + {"__dict__", T_OBJECT, offsetof(_PyNamespaceObject, ns_dict), PY_READONLY}, {NULL} }; diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c index 4b8e5ed4cfd4cd0..1b2f6049ae9792c 100644 --- a/Objects/rangeobject.c +++ b/Objects/rangeobject.c @@ -657,9 +657,9 @@ static PyMethodDef range_methods[] = { }; static PyMemberDef range_members[] = { - {"start", T_OBJECT_EX, offsetof(rangeobject, start), READONLY}, - {"stop", T_OBJECT_EX, offsetof(rangeobject, stop), READONLY}, - {"step", T_OBJECT_EX, offsetof(rangeobject, step), READONLY}, + {"start", T_OBJECT_EX, offsetof(rangeobject, start), PY_READONLY}, + {"stop", T_OBJECT_EX, offsetof(rangeobject, stop), PY_READONLY}, + {"step", T_OBJECT_EX, offsetof(rangeobject, step), PY_READONLY}, {0} }; diff --git a/Objects/sliceobject.c b/Objects/sliceobject.c index 2dcb44fdee57ed0..c12d6d95b901fbf 100644 --- a/Objects/sliceobject.c +++ b/Objects/sliceobject.c @@ -341,9 +341,9 @@ slice_repr(PySliceObject *r) } static PyMemberDef slice_members[] = { - {"start", T_OBJECT, offsetof(PySliceObject, start), READONLY}, - {"stop", T_OBJECT, offsetof(PySliceObject, stop), READONLY}, - {"step", T_OBJECT, offsetof(PySliceObject, step), READONLY}, + {"start", T_OBJECT, offsetof(PySliceObject, start), PY_READONLY}, + {"stop", T_OBJECT, offsetof(PySliceObject, stop), PY_READONLY}, + {"step", T_OBJECT, offsetof(PySliceObject, step), PY_READONLY}, {0} }; diff --git a/Objects/structseq.c b/Objects/structseq.c index 1c37845950fe413..04f839c25bbea83 100644 --- a/Objects/structseq.c +++ b/Objects/structseq.c @@ -336,7 +336,7 @@ initialize_members(PyStructSequence_Desc *desc, PyMemberDef* members, members[k].type = T_OBJECT; members[k].offset = offsetof(PyStructSequence, ob_item) + i * sizeof(PyObject*); - members[k].flags = READONLY; + members[k].flags = PY_READONLY; members[k].doc = desc->fields[i].doc; k++; } diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 403f3caaee6ae92..af1e3db10039fc7 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -366,15 +366,15 @@ assign_version_tag(PyTypeObject *type) static PyMemberDef type_members[] = { - {"__basicsize__", T_PYSSIZET, offsetof(PyTypeObject,tp_basicsize),READONLY}, - {"__itemsize__", T_PYSSIZET, offsetof(PyTypeObject, tp_itemsize), READONLY}, - {"__flags__", T_LONG, offsetof(PyTypeObject, tp_flags), READONLY}, + {"__basicsize__", T_PYSSIZET, offsetof(PyTypeObject,tp_basicsize),PY_READONLY}, + {"__itemsize__", T_PYSSIZET, offsetof(PyTypeObject, tp_itemsize), PY_READONLY}, + {"__flags__", T_LONG, offsetof(PyTypeObject, tp_flags), PY_READONLY}, {"__weakrefoffset__", T_LONG, - offsetof(PyTypeObject, tp_weaklistoffset), READONLY}, - {"__base__", T_OBJECT, offsetof(PyTypeObject, tp_base), READONLY}, + offsetof(PyTypeObject, tp_weaklistoffset), PY_READONLY}, + {"__base__", T_OBJECT, offsetof(PyTypeObject, tp_base), PY_READONLY}, {"__dictoffset__", T_LONG, - offsetof(PyTypeObject, tp_dictoffset), READONLY}, - {"__mro__", T_OBJECT, offsetof(PyTypeObject, tp_mro), READONLY}, + offsetof(PyTypeObject, tp_dictoffset), PY_READONLY}, + {"__mro__", T_OBJECT, offsetof(PyTypeObject, tp_mro), PY_READONLY}, {0} }; @@ -1076,7 +1076,7 @@ clear_slots(PyTypeObject *type, PyObject *self) n = Py_SIZE(type); mp = PyHeapType_GET_MEMBERS((PyHeapTypeObject *)type); for (i = 0; i < n; i++, mp++) { - if (mp->type == T_OBJECT_EX && !(mp->flags & READONLY)) { + if (mp->type == T_OBJECT_EX && !(mp->flags & PY_READONLY)) { char *addr = (char *)self + mp->offset; PyObject *obj = *(PyObject **)addr; if (obj != NULL) { @@ -7586,11 +7586,11 @@ typedef struct { } superobject; static PyMemberDef super_members[] = { - {"__thisclass__", T_OBJECT, offsetof(superobject, type), READONLY, + {"__thisclass__", T_OBJECT, offsetof(superobject, type), PY_READONLY, "the class invoking super()"}, - {"__self__", T_OBJECT, offsetof(superobject, obj), READONLY, + {"__self__", T_OBJECT, offsetof(superobject, obj), PY_READONLY, "the instance invoking super(); may be None"}, - {"__self_class__", T_OBJECT, offsetof(superobject, obj_type), READONLY, + {"__self_class__", T_OBJECT, offsetof(superobject, obj_type), PY_READONLY, "the type of the instance invoking super(); may be None"}, {0} }; diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c index 9227aa688f47e1d..16d7e36ce8c2ba7 100644 --- a/Objects/weakrefobject.c +++ b/Objects/weakrefobject.c @@ -343,7 +343,7 @@ weakref___init__(PyObject *self, PyObject *args, PyObject *kwargs) static PyMemberDef weakref_members[] = { - {"__callback__", T_OBJECT, offsetof(PyWeakReference, wr_callback), READONLY}, + {"__callback__", T_OBJECT, offsetof(PyWeakReference, wr_callback), PY_READONLY}, {NULL} /* Sentinel */ }; diff --git a/PC/winreg.c b/PC/winreg.c index 3a6ea3689fd12a0..e8de9c0a1a8a35f 100644 --- a/PC/winreg.c +++ b/PC/winreg.c @@ -342,7 +342,7 @@ static struct PyMethodDef PyHKEY_methods[] = { #define OFF(e) offsetof(PyHKEYObject, e) static PyMemberDef PyHKEY_memberlist[] = { - {"handle", T_INT, OFF(hkey), READONLY}, + {"handle", T_INT, OFF(hkey), PY_READONLY}, {NULL} /* Sentinel */ }; diff --git a/Python/context.c b/Python/context.c index 9a50ea91a77ee3d..c2a367be904c5a3 100644 --- a/Python/context.c +++ b/Python/context.c @@ -1016,7 +1016,7 @@ contextvar_cls_getitem(PyObject *self, PyObject *args) } static PyMemberDef PyContextVar_members[] = { - {"name", T_OBJECT, offsetof(PyContextVar, var_name), READONLY}, + {"name", T_OBJECT, offsetof(PyContextVar, var_name), PY_READONLY}, {NULL} }; diff --git a/Python/structmember.c b/Python/structmember.c index e653d0277c1a106..b408d111ac5e6ae 100644 --- a/Python/structmember.c +++ b/Python/structmember.c @@ -104,7 +104,7 @@ PyMember_SetOne(char *addr, PyMemberDef *l, PyObject *v) addr += l->offset; - if ((l->flags & READONLY)) + if ((l->flags & PY_READONLY)) { PyErr_SetString(PyExc_AttributeError, "readonly attribute"); return -1; diff --git a/Python/symtable.c b/Python/symtable.c index 1d68a7d939fa544..c65603f9dd05d55 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -123,14 +123,14 @@ ste_dealloc(PySTEntryObject *ste) #define OFF(x) offsetof(PySTEntryObject, x) static PyMemberDef ste_memberlist[] = { - {"id", T_OBJECT, OFF(ste_id), READONLY}, - {"name", T_OBJECT, OFF(ste_name), READONLY}, - {"symbols", T_OBJECT, OFF(ste_symbols), READONLY}, - {"varnames", T_OBJECT, OFF(ste_varnames), READONLY}, - {"children", T_OBJECT, OFF(ste_children), READONLY}, - {"nested", T_INT, OFF(ste_nested), READONLY}, - {"type", T_INT, OFF(ste_type), READONLY}, - {"lineno", T_INT, OFF(ste_lineno), READONLY}, + {"id", T_OBJECT, OFF(ste_id), PY_READONLY}, + {"name", T_OBJECT, OFF(ste_name), PY_READONLY}, + {"symbols", T_OBJECT, OFF(ste_symbols), PY_READONLY}, + {"varnames", T_OBJECT, OFF(ste_varnames), PY_READONLY}, + {"children", T_OBJECT, OFF(ste_children), PY_READONLY}, + {"nested", T_INT, OFF(ste_nested), PY_READONLY}, + {"type", T_INT, OFF(ste_type), PY_READONLY}, + {"lineno", T_INT, OFF(ste_lineno), PY_READONLY}, {NULL} }; diff --git a/Python/traceback.c b/Python/traceback.c index bd1061ed43b1e13..3ac9c331beb589b 100644 --- a/Python/traceback.c +++ b/Python/traceback.c @@ -148,9 +148,9 @@ static PyMethodDef tb_methods[] = { }; static PyMemberDef tb_memberlist[] = { - {"tb_frame", T_OBJECT, OFF(tb_frame), READONLY}, - {"tb_lasti", T_INT, OFF(tb_lasti), READONLY}, - {"tb_lineno", T_INT, OFF(tb_lineno), READONLY}, + {"tb_frame", T_OBJECT, OFF(tb_frame), PY_READONLY}, + {"tb_lasti", T_INT, OFF(tb_lasti), PY_READONLY}, + {"tb_lineno", T_INT, OFF(tb_lineno), PY_READONLY}, {NULL} /* Sentinel */ };