This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Remove documentation and internal use of the *RESTRICTED constants for PyMemberDef's flags field
Type: Stage:
Components: Documentation, Extension Modules, Interpreter Core Versions: Python 3.8
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, josh.r, matrixise
Priority: normal Keywords:

Created on 2019-03-18 19:18 by josh.r, last changed 2022-04-11 14:59 by admin.

Messages (5)
msg338282 - (view) Author: Josh Rosenberg (josh.r) * (Python triager) Date: 2019-03-18 19:18
While looking up background info for #36347, I noticed that the docs for PyMemberDef ( https://docs.python.org/3/extending/newtypes.html#generic-attribute-management ) define the following flags:

* READONLY
* READ_RESTRICTED
* WRITE_RESTRICTED
* RESTRICTED

Of those, WRITE_RESTRICTED has been documented incorrectly since Python 3.0a2 (it got renamed to PY_WRITE_RESTRICTED in structmember.h, apparently due to a name clash with VS 2008 on Windows).

Luckily, the constants are useless; AFAICT they were there solely to support restricted mode (via the rexec and Bastion modules). The modules were apparently disabled in Python 2.3 "due to various known and not readily fixable security holes" ( https://docs.python.org/2/library/restricted.html ), and the modules themselves officially deprecated in 2.6, and removed completely in 3.0.

Rather than fixing up the docs, maybe it's time to kill these constants for good? Probably shouldn't remove the definitions in structmember.h (if someone wrote code using them, we shouldn't needlessly break compilation), but the interpreter and standard library should stop setting them, and the documentation for them should be removed.
msg338283 - (view) Author: Josh Rosenberg (josh.r) * (Python triager) Date: 2019-03-18 19:20
To be clear, only the constants that include the substring RESTRICTED are useless; READONLY remains useful and should not be removed (though per my suggestion on #36347, it might be good to add an alias for it named PY_READONLY to match the Python C API naming conventions).
msg338455 - (view) Author: Stéphane Wirtel (matrixise) * (Python committer) Date: 2019-03-20 10:46
Josh, I don't know for the uselessness or not of these macros, but these macros are used.

RESTRICTED is used in Objects/classobject.c and Objects/funcobject.c

PY_WRITE_RESTRICTED is used in Objects/funcobject.c and Objects/methodobject.c
msg338517 - (view) Author: Josh Rosenberg (josh.r) * (Python triager) Date: 2019-03-21 00:24
Yes, they're set. They're never *read* anywhere. My suggestion was to stop setting them (because it gives the impression they do something when reading the docs, when in fact they do nothing), and remove them from the docs.
msg338518 - (view) Author: Josh Rosenberg (josh.r) * (Python triager) Date: 2019-03-21 00:25
Sorry, that should have been "it gives the impression they do something when reading the *source code*"
History
Date User Action Args
2022-04-11 14:59:12adminsetgithub: 80536
2019-03-21 00:25:24josh.rsetmessages: + msg338518
2019-03-21 00:24:46josh.rsetmessages: + msg338517
2019-03-20 10:46:22matrixisesetnosy: + matrixise
messages: + msg338455
2019-03-18 19:20:23josh.rsetmessages: + msg338283
title: Remove documentation and internal use of the RESTRICTED constants for PyMemberDef's flags field -> Remove documentation and internal use of the *RESTRICTED constants for PyMemberDef's flags field
2019-03-18 19:18:19josh.rcreate