Skip to content

Commit 24bba8c

Browse files
authored
bpo-36347: stop using RESTRICTED constants (GH-12684)
The constants `RESTRICTED` and `PY_WRITE_RESTRICTED` no longer have a meaning in Python 3. Therefore, CPython should not use them. CC @matrixise https://bugs.python.org/issue36347
1 parent 5d38517 commit 24bba8c

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

Objects/classobject.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,9 @@ static PyMethodDef method_methods[] = {
145145
#define MO_OFF(x) offsetof(PyMethodObject, x)
146146

147147
static PyMemberDef method_memberlist[] = {
148-
{"__func__", T_OBJECT, MO_OFF(im_func), READONLY|RESTRICTED,
148+
{"__func__", T_OBJECT, MO_OFF(im_func), READONLY,
149149
"the function (or other callable) implementing a method"},
150-
{"__self__", T_OBJECT, MO_OFF(im_self), READONLY|RESTRICTED,
150+
{"__self__", T_OBJECT, MO_OFF(im_self), READONLY,
151151
"the instance to which a method is bound"},
152152
{NULL} /* Sentinel */
153153
};
@@ -400,7 +400,7 @@ PyInstanceMethod_Function(PyObject *im)
400400
#define IMO_OFF(x) offsetof(PyInstanceMethodObject, x)
401401

402402
static PyMemberDef instancemethod_memberlist[] = {
403-
{"__func__", T_OBJECT, IMO_OFF(func), READONLY|RESTRICTED,
403+
{"__func__", T_OBJECT, IMO_OFF(func), READONLY,
404404
"the function (or other callable) implementing a method"},
405405
{NULL} /* Sentinel */
406406
};

Objects/funcobject.c

+4-6
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,10 @@ PyFunction_SetAnnotations(PyObject *op, PyObject *annotations)
239239
#define OFF(x) offsetof(PyFunctionObject, x)
240240

241241
static PyMemberDef func_memberlist[] = {
242-
{"__closure__", T_OBJECT, OFF(func_closure),
243-
RESTRICTED|READONLY},
244-
{"__doc__", T_OBJECT, OFF(func_doc), PY_WRITE_RESTRICTED},
245-
{"__globals__", T_OBJECT, OFF(func_globals),
246-
RESTRICTED|READONLY},
247-
{"__module__", T_OBJECT, OFF(func_module), PY_WRITE_RESTRICTED},
242+
{"__closure__", T_OBJECT, OFF(func_closure), READONLY},
243+
{"__doc__", T_OBJECT, OFF(func_doc), 0},
244+
{"__globals__", T_OBJECT, OFF(func_globals), READONLY},
245+
{"__module__", T_OBJECT, OFF(func_module), 0},
248246
{NULL} /* Sentinel */
249247
};
250248

Objects/methodobject.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ static PyGetSetDef meth_getsets [] = {
222222
#define OFF(x) offsetof(PyCFunctionObject, x)
223223

224224
static PyMemberDef meth_members[] = {
225-
{"__module__", T_OBJECT, OFF(m_module), PY_WRITE_RESTRICTED},
225+
{"__module__", T_OBJECT, OFF(m_module), 0},
226226
{NULL}
227227
};
228228

0 commit comments

Comments
 (0)