Issue 43973: Use Py_TPFLAGS_IMMUTABLETYPE in class assignments check (original) (raw)

Created on 2021-04-29 08:27 by erlendaasland, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 25714 merged erlendaasland,2021-04-29 09:30
Messages (7)
msg392290 - (view) Author: Erlend E. Aasland (erlendaasland) * (Python triager) Date: 2021-04-29 08:27
Use Py_TPFLAGS_IMMUTABLETYPE iso. Py_TPFLAGS_HEAPTYPE in object_set_class(). See also: - bpo-43908 (particularly ) - bpo-24912 - https://github.com/python/cpython/blob/e047239eafefe8b19725efffe7756443495cf78b/Objects/typeobject.c#L4620-L4668
msg392291 - (view) Author: Erlend E. Aasland (erlendaasland) * (Python triager) Date: 2021-04-29 08:35
IMO, we can drop most (all?) of the huge comment before the check in object_set_class(). History is preserved in the git log. Contrary to Py_TPFLAGS_HEAPTYPE, using Py_TPFLAGS_IMMUTABLETYPE speaks for itself. We might reduce it to just refer to to bpo-43908 and bpo-24912. Something a la this: /* Historically, only static types were immutable. * Py_TPFLAGS_IMMUTABLETYPE was introduced in Python 3.10. * See bpo-43908 and bpo-24912. */ What do you think?
msg392313 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-04-29 14:17
> IMO, we can drop most (all?) of the huge comment before the check in object_set_class(). I don't think so. I don't understand why it's allowed to override the __class__ attribute of ModuleType instances whereas it's a static type. IMO the long comment remains useful and something should be done later to make the condition more generic, rather than checking PyType_IsSubtype(newto, &PyModule_Type) specifically.
msg392404 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-04-30 10:07
New changeset b73b5fb9ea08156991a065c1696e8d8cf7622482 by Erlend Egeberg Aasland in branch 'master': bpo-43973: object_set_class() checks Py_TPFLAGS_IMMUTABLETYPE (GH-25714) https://github.com/python/cpython/commit/b73b5fb9ea08156991a065c1696e8d8cf7622482
msg392405 - (view) Author: Erlend E. Aasland (erlendaasland) * (Python triager) Date: 2021-04-30 10:09
Ok! Did you see bpo-24912 regarding the ModuleType check?
msg392412 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-04-30 10:44
> Ok! Did you see bpo-24912 regarding the ModuleType check? No, I didn't. Sorry, there are too many things to look at, and too little bit. Do you think that something should be changed? If yes, please open a new separated issue.
msg392415 - (view) Author: Erlend E. Aasland (erlendaasland) * (Python triager) Date: 2021-04-30 10:58
> Do you think that something should be changed? If yes, please open a new separated issue. No, my comment was just for information :)
History
Date User Action Args
2022-04-11 14:59:44 admin set github: 88139
2021-04-30 10:58:54 erlendaasland set messages: +
2021-04-30 10:44:41 vstinner set messages: +
2021-04-30 10:09:43 erlendaasland set status: open -> closedresolution: fixedstage: patch review -> resolved
2021-04-30 10:09:20 erlendaasland set messages: +
2021-04-30 10:07:09 vstinner set messages: +
2021-04-29 14:17:50 vstinner set messages: +
2021-04-29 12:44:00 shreyanavigyan set nosy: + shreyanavigyan
2021-04-29 09:30:02 erlendaasland set keywords: + patchstage: patch reviewpull_requests: + <pull%5Frequest24403>
2021-04-29 08:35:19 erlendaasland set messages: +
2021-04-29 08:27:05 erlendaasland create