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: Better explain the GC contract for PyType_FromSpecWithBases
Type: Stage: resolved
Components: C API, Interpreter Core Versions: Python 3.11
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: erlendaasland, miss-islington, pablogsal, shihai1991, vstinner
Priority: normal Keywords: patch

Created on 2021-05-29 00:00 by pablogsal, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 26442 merged pablogsal, 2021-05-29 00:01
PR 26443 merged miss-islington, 2021-05-29 02:57
PR 26444 merged miss-islington, 2021-05-29 02:57
PR 26445 merged pablogsal, 2021-05-29 03:10
PR 26446 merged miss-islington, 2021-05-29 03:32
PR 26447 merged miss-islington, 2021-05-29 03:32
PR 26463 merged vstinner, 2021-05-31 09:37
PR 26464 merged vstinner, 2021-05-31 09:46
PR 26465 merged miss-islington, 2021-05-31 11:10
PR 26466 merged miss-islington, 2021-05-31 11:11
Messages (13)
msg394706 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-05-29 00:00
We currently don't properly document how PyType_FromSpecWithBases behaves if the class is inheriting from some other class with GC support.
msg394708 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-05-29 02:57
New changeset 8b55bc3f93a655bc803bff79725d5fe3f124e2f0 by Pablo Galindo in branch 'main':
bpo-44263: Better explain the GC contract for PyType_FromSpecWithBases (GH-26442)
https://github.com/python/cpython/commit/8b55bc3f93a655bc803bff79725d5fe3f124e2f0
msg394709 - (view) Author: miss-islington (miss-islington) Date: 2021-05-29 03:21
New changeset a30cbaee84262cdd4597f3204861ccdd86bbf533 by Miss Islington (bot) in branch '3.9':
bpo-44263: Better explain the GC contract for PyType_FromSpecWithBases (GH-26442)
https://github.com/python/cpython/commit/a30cbaee84262cdd4597f3204861ccdd86bbf533
msg394710 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-05-29 03:21
New changeset 11049bece15b6fa08fa6d74aea8eb6bc2ebadfe5 by Miss Islington (bot) in branch '3.10':
bpo-44263: Better explain the GC contract for PyType_FromSpecWithBases (GH-26442) (GH-26443)
https://github.com/python/cpython/commit/11049bece15b6fa08fa6d74aea8eb6bc2ebadfe5
msg394711 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-05-29 03:32
New changeset 43cf7c864a2941b3f8f823e5928721dd286b7778 by Pablo Galindo in branch 'main':
bpo-44263: Mention PyType_Ready in the gc protocol warning (GH-26445)
https://github.com/python/cpython/commit/43cf7c864a2941b3f8f823e5928721dd286b7778
msg394712 - (view) Author: miss-islington (miss-islington) Date: 2021-05-29 03:53
New changeset 7bd1304d49a110700b3f079e4b2dd1052a23bde4 by Miss Islington (bot) in branch '3.9':
bpo-44263: Mention PyType_Ready in the gc protocol warning (GH-26445)
https://github.com/python/cpython/commit/7bd1304d49a110700b3f079e4b2dd1052a23bde4
msg394733 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-05-29 17:49
New changeset d8ce746e7c5193757c8d316105870b0dc5d6fa53 by Miss Islington (bot) in branch '3.10':
bpo-44263: Mention PyType_Ready in the gc protocol warning (GH-26445) (#26446)
https://github.com/python/cpython/commit/d8ce746e7c5193757c8d316105870b0dc5d6fa53
msg394799 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-05-31 09:19
I reopen the issue. I would prefer to change PyType_FromSpecWithBases() to raise an error if a type has the Py_TPFLAGS_HAVE_GC flag but its tp_traverse function is NULL.

Oops, the Python stdlib has more types than only _ssl.SSLError with this error:

* _decimal: PyDecSignalDictMixin_Type (internal type)
* _testcapi: heapctype
msg394800 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-05-31 11:11
New changeset 142e5c5445c019542246d93fe2f9e195d3131686 by Victor Stinner in branch 'main':
bpo-44263: Fix _decimal and _testcapi GC protocol (GH-26464)
https://github.com/python/cpython/commit/142e5c5445c019542246d93fe2f9e195d3131686
msg394802 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-05-31 11:25
New changeset 7fe9cad606a4ac7ac138528dcd19546394bc5a44 by Miss Islington (bot) in branch '3.10':
bpo-44263: Fix _decimal and _testcapi GC protocol (GH-26464) (GH-26465)
https://github.com/python/cpython/commit/7fe9cad606a4ac7ac138528dcd19546394bc5a44
msg394803 - (view) Author: miss-islington (miss-islington) Date: 2021-05-31 11:33
New changeset 46b16d0bdbb1722daed10389e27226a2370f1635 by Miss Islington (bot) in branch '3.9':
bpo-44263: Fix _decimal and _testcapi GC protocol (GH-26464)
https://github.com/python/cpython/commit/46b16d0bdbb1722daed10389e27226a2370f1635
msg394872 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-06-01 21:37
New changeset ee7637596d8de25f54261bbeabc602d31e74f482 by Victor Stinner in branch 'main':
bpo-44263: Py_TPFLAGS_HAVE_GC requires tp_traverse (GH-26463)
https://github.com/python/cpython/commit/ee7637596d8de25f54261bbeabc602d31e74f482
msg394873 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-06-01 21:39
I made sure that it's no longer possible to create a type with Py_TPFLAGS_HAVE_GC flag set but with no traverse function (tp_traverse=NULL). I close again the issue.
History
Date User Action Args
2022-04-11 14:59:46adminsetgithub: 88429
2021-06-01 21:39:22vstinnersetstatus: open -> closed
versions: + Python 3.11
messages: + msg394873

components: + Interpreter Core, C API
resolution: fixed
stage: patch review -> resolved
2021-06-01 21:37:17vstinnersetmessages: + msg394872
2021-05-31 11:37:50shihai1991setnosy: + shihai1991
2021-05-31 11:33:35miss-islingtonsetmessages: + msg394803
2021-05-31 11:25:54pablogsalsetmessages: + msg394802
2021-05-31 11:11:58miss-islingtonsetpull_requests: + pull_request25061
2021-05-31 11:11:07vstinnersetmessages: + msg394800
2021-05-31 11:10:42miss-islingtonsetpull_requests: + pull_request25060
2021-05-31 09:46:12vstinnersetpull_requests: + pull_request25059
2021-05-31 09:45:26erlendaaslandsetnosy: + erlendaasland
2021-05-31 09:37:37vstinnersetstage: resolved -> patch review
pull_requests: + pull_request25058
2021-05-31 09:19:55vstinnersetstatus: closed -> open
nosy: + vstinner
messages: + msg394799

2021-05-29 17:49:24pablogsalsetmessages: + msg394733
2021-05-29 03:53:48miss-islingtonsetmessages: + msg394712
2021-05-29 03:44:12pablogsalsetstatus: open -> closed
stage: patch review -> resolved
2021-05-29 03:32:54miss-islingtonsetpull_requests: + pull_request25041
2021-05-29 03:32:49miss-islingtonsetpull_requests: + pull_request25040
2021-05-29 03:32:49pablogsalsetmessages: + msg394711
2021-05-29 03:21:29pablogsalsetmessages: + msg394710
2021-05-29 03:21:01miss-islingtonsetmessages: + msg394709
2021-05-29 03:10:49pablogsalsetpull_requests: + pull_request25038
2021-05-29 02:57:53pablogsalsetmessages: + msg394708
2021-05-29 02:57:51miss-islingtonsetpull_requests: + pull_request25036
2021-05-29 02:57:46miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request25035
2021-05-29 00:01:08pablogsalsetkeywords: + patch
stage: patch review
pull_requests: + pull_request25034
2021-05-29 00:00:31pablogsalcreate