classification
Title: [C API] PyThreadState_GetFrame() and PyFrame_GetCode() should return a strong refrence
Type: Stage: resolved
Components: C API Versions: Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: vstinner
Priority: normal Keywords: patch

Created on 2020-04-28 21:55 by vstinner, last changed 2020-05-14 01:19 by vstinner. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 19772 merged vstinner, 2020-04-28 22:35
PR 19773 merged vstinner, 2020-04-28 23:06
PR 19776 merged vstinner, 2020-04-28 23:32
PR 19781 merged vstinner, 2020-04-29 00:36
Messages (5)
msg367570 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-04-28 21:55
I recently added PyThreadState_GetFrame() and PyFrame_GetCode() functions to the C API of Python 3.9.

Currently, these functions return borrowed references.

I asked on capi-sig and Brett confirms that borrowed refrences should be avoided:
https://mail.python.org/archives/list/capi-sig@python.org/thread/LHESBBB3IYTXMBUKQ3WZI5CWB4WUH5YZ/

Borrowed references should be avoidedd!
https://github.com/vstinner/misc/blob/master/cpython/pep-opaque-c-api.rst#borrowed-references

I will work on a PR to modify these functions to return a strong reference instead.
msg367572 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-04-28 22:57
New changeset 6d86a2331e6b64a2ae80c1a21f81baa5a71ac594 by Victor Stinner in branch 'master':
bpo-40429: PyFrame_GetCode() result cannot be NULL (GH-19772)
https://github.com/python/cpython/commit/6d86a2331e6b64a2ae80c1a21f81baa5a71ac594
msg367574 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-04-28 23:28
New changeset 8852ad4208e34825f74e24945edb5bcf055d94fe by Victor Stinner in branch 'master':
bpo-40429: PyFrame_GetCode() now returns a strong reference (GH-19773)
https://github.com/python/cpython/commit/8852ad4208e34825f74e24945edb5bcf055d94fe
msg367594 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-04-29 00:28
New changeset cc0dc7e484c9626857e9a8b4c40eee37473702ed by Victor Stinner in branch 'master':
bpo-40429: Refactor super_init() (GH-19776)
https://github.com/python/cpython/commit/cc0dc7e484c9626857e9a8b4c40eee37473702ed
msg367601 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-04-29 01:01
New changeset 4386b9045e5fe1151e65c2816264b5710000eb9f by Victor Stinner in branch 'master':
bpo-40429: PyThreadState_GetFrame() returns a strong ref (GH-19781)
https://github.com/python/cpython/commit/4386b9045e5fe1151e65c2816264b5710000eb9f
History
Date User Action Args
2020-05-14 01:19:36vstinnersetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-04-29 01:01:49vstinnersetmessages: + msg367601
2020-04-29 00:36:23vstinnersetpull_requests: + pull_request19101
2020-04-29 00:28:30vstinnersetmessages: + msg367594
2020-04-28 23:32:56vstinnersetpull_requests: + pull_request19096
2020-04-28 23:28:19vstinnersetmessages: + msg367574
2020-04-28 23:06:03vstinnersetpull_requests: + pull_request19093
2020-04-28 22:57:01vstinnersetmessages: + msg367572
2020-04-28 22:35:30vstinnersetkeywords: + patch
stage: patch review
pull_requests: + pull_request19092
2020-04-28 21:55:17vstinnercreate