Issue 30372: Status of builtins is not totally clear (original) (raw)
Created on 2017-05-15 16:20 by Malcolm Smith, last changed 2022-04-11 14:58 by admin. This issue is now closed.
Pull Requests | |||
---|---|---|---|
URL | Status | Linked | Edit |
PR 1725 | merged | NaomiCeder,2017-05-22 20:40 | |
PR 1727 | merged | Mariatta,2017-05-22 21:17 |
Messages (7) | ||
---|---|---|
msg293722 - (view) | Author: Malcolm Smith (Malcolm Smith) | Date: 2017-05-15 16:20 |
https://docs.python.org/3.6/reference/executionmodel.html#builtins-and-restricted-execution describes the various things you can do with __builtins__, but then says "Users should not touch __builtins__; it is strictly an implementation detail." If this is so, the entire section should be marked "CPython implementation detail", not just that last paragraph. Elsewhere, https://docs.python.org/3.6/reference/import.html#replacing-the-standard-import-system suggests that the __import__ function could be replaced "at the module level to only alter the behaviour of import statements within that module". Is there any way of doing this other than manipulating the module's __builtins__? If not, this is encouraging the programmer to rely on a CPython implementation detail without marking it as such. | ||
msg293773 - (view) | Author: Brett Cannon (brett.cannon) * ![]() |
Date: 2017-05-16 16:28 |
You're correct that both are CPython implementation details and could be more clearly marked as such. (In case anyone is curious, the code to look up __import__() can be found at https://github.com/python/cpython/blob/c7ac7280c321b3c1679fe5f657a6be0f86adf173/Python/ceval.c#L4991 .) | ||
msg293972 - (view) | Author: Terry J. Reedy (terry.reedy) * ![]() |
Date: 2017-05-19 20:06 |
Moving "CPython implementation detail: " up a paragraph should be trivial. Resolving the conflict between " __builtins__ can be set to a user-created dictionary to create a weak form of restricted execution." and "Users should not touch __builtins__;" seems less so. I suspect the the latter was added well after the former, and that the former should have been deleted at that time. | ||
msg294181 - (view) | Author: Naomi Ceder (NaomiCeder) * | Date: 2017-05-22 20:41 |
Created a PR on this... it seems that making the Implementation Detail warning come first and deleting the limited execution sentence achieves what's needed here. | ||
msg294183 - (view) | Author: Mariatta (Mariatta) * ![]() |
Date: 2017-05-22 21:09 |
New changeset 43c8a9e39bb2d4f25ed7ae17a55f34e375d1868b by Mariatta (Naomi Ceder) in branch 'master': bpo-30372: Clarify that '__builtins__' is a CPython Implementation detail (GH-1725) https://github.com/python/cpython/commit/43c8a9e39bb2d4f25ed7ae17a55f34e375d1868b | ||
msg294188 - (view) | Author: Mariatta (Mariatta) * ![]() |
Date: 2017-05-22 21:36 |
New changeset 3d3b189f8ef321ccfb144a46d50892939d6004aa by Mariatta in branch '3.6': [3.6] bpo-30372: Clarify that '__builtins__' is a CPython Implementation detail (GH-1725) (GH-1727) https://github.com/python/cpython/commit/3d3b189f8ef321ccfb144a46d50892939d6004aa | ||
msg294189 - (view) | Author: Mariatta (Mariatta) * ![]() |
Date: 2017-05-22 21:37 |
PR merged, and I backport it to 3.6 Thanks everyone :) |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:58:46 | admin | set | github: 74557 |
2017-05-22 21:37:09 | Mariatta | set | status: open -> closedresolution: fixedmessages: + stage: patch review -> resolved |
2017-05-22 21:36:21 | Mariatta | set | messages: + |
2017-05-22 21:17:05 | Mariatta | set | pull_requests: + <pull%5Frequest1817> |
2017-05-22 21:09:57 | Mariatta | set | nosy: + Mariattamessages: + |
2017-05-22 20:50:13 | Mariatta | set | stage: needs patch -> patch reviewversions: + Python 3.7 |
2017-05-22 20:41:19 | NaomiCeder | set | nosy: + NaomiCedermessages: + |
2017-05-22 20:40:12 | NaomiCeder | set | pull_requests: + <pull%5Frequest1813> |
2017-05-19 20:06:01 | terry.reedy | set | nosy: + terry.reedymessages: + type: behaviorstage: needs patch |
2017-05-16 16:28:00 | brett.cannon | set | nosy: + brett.cannonmessages: + |
2017-05-15 16:20:38 | Malcolm Smith | create |