diff -r fa09ba71babb Doc/extending/newtypes.rst --- a/Doc/extending/newtypes.rst Tue Oct 04 20:54:44 2016 +0300 +++ b/Doc/extending/newtypes.rst Wed Oct 05 12:19:16 2016 -0400 @@ -1131,6 +1131,9 @@ at the end; it is a sentinel that marks the end of the array. The :attr:`ml_name` field of the sentinel must be *NULL*. +.. index:: + single: READONLY + The second table is used to define attributes which map directly to data stored 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:: @@ -1147,29 +1150,10 @@ type which will be able to extract a value from the instance structure. The :attr:`type` field should contain one of the type codes defined in the :file:`structmember.h` header; the value will be used to determine how to -convert Python values to and from C values. The :attr:`flags` field is used to -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. | -+---------------------------+----------------------------------------------+ - -.. index:: - single: READONLY - single: READ_RESTRICTED - single: WRITE_RESTRICTED - single: RESTRICTED +convert Python values to and from C values. The :attr:`flags` field control +how the attribute can be accessed. If :attr:`flags` is set to :const:`READONLY` +(defined in the :file:`structmember.h` header), the attribute is read-only; otherwise +it should be set to `0`. 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