diff --git a/Doc/extending/newtypes.rst b/Doc/extending/newtypes.rst index 545390c2e46..6e17897ed2c 100644 --- a/Doc/extending/newtypes.rst +++ b/Doc/extending/newtypes.rst @@ -287,7 +287,7 @@ combined using bitwise-OR. +===========================+==============================================+ | :const:`READONLY` | Never writable. | +---------------------------+----------------------------------------------+ -| :const:`AUDIT_READ` | Emit an ``object.__getattr__`` | +| :const:`PY_AUDIT_READ` | Emit an ``object.__getattr__`` | | | :ref:`audit events ` before | | | reading. | +---------------------------+----------------------------------------------+ @@ -295,15 +295,15 @@ combined using bitwise-OR. .. versionchanged:: 3.10 :const:`RESTRICTED`, :const:`READ_RESTRICTED` and :const:`WRITE_RESTRICTED` are deprecated. However, :const:`READ_RESTRICTED` is an alias for - :const:`AUDIT_READ`, so fields that specify either :const:`RESTRICTED` or - :const:`READ_RESTRICTED` will also raise an audit event. + :const:`PY_AUDIT_READ`, so fields that specify either :const:`RESTRICTED` + or :const:`READ_RESTRICTED` will also raise an audit event. .. index:: single: READONLY single: READ_RESTRICTED single: WRITE_RESTRICTED single: RESTRICTED - single: AUDIT_READ + single: PY_AUDIT_READ 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/Include/structmember.h b/Include/structmember.h index 955edd31c4c..93b7aff8091 100644 --- a/Include/structmember.h +++ b/Include/structmember.h @@ -62,7 +62,7 @@ typedef struct PyMemberDef { #define PY_WRITE_RESTRICTED 4 #define RESTRICTED (READ_RESTRICTED | PY_WRITE_RESTRICTED) -#define AUDIT_READ READ_RESTRICTED +#define PY_AUDIT_READ READ_RESTRICTED /* Current API, use this */ PyAPI_FUNC(PyObject *) PyMember_GetOne(const char *, struct PyMemberDef *); diff --git a/Objects/descrobject.c b/Objects/descrobject.c index 297b8528a64..dd41620b9a9 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -164,7 +164,7 @@ member_get(PyMemberDescrObject *descr, PyObject *obj, PyObject *type) if (descr_check((PyDescrObject *)descr, obj, &res)) return res; - if (descr->d_member->flags & AUDIT_READ) { + if (descr->d_member->flags & PY_AUDIT_READ) { if (PySys_Audit("object.__getattr__", "Os", obj ? obj : Py_None, descr->d_member->name) < 0) { return NULL; diff --git a/Objects/frameobject.c b/Objects/frameobject.c index 5c337467155..034b908ade3 100644 --- a/Objects/frameobject.c +++ b/Objects/frameobject.c @@ -13,7 +13,7 @@ static PyMemberDef frame_memberlist[] = { {"f_back", T_OBJECT, OFF(f_back), READONLY}, - {"f_code", T_OBJECT, OFF(f_code), READONLY|AUDIT_READ}, + {"f_code", T_OBJECT, OFF(f_code), READONLY|PY_AUDIT_READ}, {"f_builtins", T_OBJECT, OFF(f_builtins), READONLY}, {"f_globals", T_OBJECT, OFF(f_globals), READONLY}, {"f_trace_lines", T_BOOL, OFF(f_trace_lines), 0}, diff --git a/Objects/genobject.c b/Objects/genobject.c index a922d45de10..1889df1d137 100644 --- a/Objects/genobject.c +++ b/Objects/genobject.c @@ -741,8 +741,8 @@ static PyGetSetDef gen_getsetlist[] = { }; static PyMemberDef gen_memberlist[] = { - {"gi_frame", T_OBJECT, offsetof(PyGenObject, gi_frame), READONLY|AUDIT_READ}, - {"gi_code", T_OBJECT, offsetof(PyGenObject, gi_code), READONLY|AUDIT_READ}, + {"gi_frame", T_OBJECT, offsetof(PyGenObject, gi_frame), READONLY|PY_AUDIT_READ}, + {"gi_code", T_OBJECT, offsetof(PyGenObject, gi_code), READONLY|PY_AUDIT_READ}, {NULL} /* Sentinel */ }; @@ -978,8 +978,8 @@ static PyGetSetDef coro_getsetlist[] = { }; static PyMemberDef coro_memberlist[] = { - {"cr_frame", T_OBJECT, offsetof(PyCoroObject, cr_frame), READONLY|AUDIT_READ}, - {"cr_code", T_OBJECT, offsetof(PyCoroObject, cr_code), READONLY|AUDIT_READ}, + {"cr_frame", T_OBJECT, offsetof(PyCoroObject, cr_frame), READONLY|PY_AUDIT_READ}, + {"cr_code", T_OBJECT, offsetof(PyCoroObject, cr_code), READONLY|PY_AUDIT_READ}, {"cr_origin", T_OBJECT, offsetof(PyCoroObject, cr_origin), READONLY}, {NULL} /* Sentinel */ }; @@ -1360,10 +1360,10 @@ static PyGetSetDef async_gen_getsetlist[] = { }; static PyMemberDef async_gen_memberlist[] = { - {"ag_frame", T_OBJECT, offsetof(PyAsyncGenObject, ag_frame), READONLY|AUDIT_READ}, + {"ag_frame", T_OBJECT, offsetof(PyAsyncGenObject, ag_frame), READONLY|PY_AUDIT_READ}, {"ag_running", T_BOOL, offsetof(PyAsyncGenObject, ag_running_async), READONLY}, - {"ag_code", T_OBJECT, offsetof(PyAsyncGenObject, ag_code), READONLY|AUDIT_READ}, + {"ag_code", T_OBJECT, offsetof(PyAsyncGenObject, ag_code), READONLY|PY_AUDIT_READ}, {NULL} /* Sentinel */ }; diff --git a/Python/traceback.c b/Python/traceback.c index 5fa6e50d33b..470324b1afd 100644 --- a/Python/traceback.c +++ b/Python/traceback.c @@ -147,7 +147,7 @@ static PyMethodDef tb_methods[] = { }; static PyMemberDef tb_memberlist[] = { - {"tb_frame", T_OBJECT, OFF(tb_frame), READONLY|AUDIT_READ}, + {"tb_frame", T_OBJECT, OFF(tb_frame), READONLY|PY_AUDIT_READ}, {"tb_lasti", T_INT, OFF(tb_lasti), READONLY}, {"tb_lineno", T_INT, OFF(tb_lineno), READONLY}, {NULL} /* Sentinel */