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: Docs do not show PyImport_AddModuleObject() returns a borrowed reference.
Type: enhancement Stage: resolved
Components: Documentation Versions: Python 3.8, Python 3.7, Python 3.6, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: aaqaishtyaq, ammar2, docs@python, eric.snow, miss-islington, ned.deily, serhiy.storchaka
Priority: normal Keywords: easy, patch

Created on 2018-12-12 19:11 by eric.snow, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 11142 merged serhiy.storchaka, 2018-12-13 10:24
PR 11198 merged miss-islington, 2018-12-17 15:30
PR 11199 merged miss-islington, 2018-12-17 15:30
Messages (8)
msg331716 - (view) Author: Eric Snow (eric.snow) * (Python committer) Date: 2018-12-12 19:11
In the C-API documentation the entry for PyImport_AddModuleObject[1] does not indicate that it returns a borrowed reference.

[1] https://docs.python.org/3/c-api/import.html#c.PyImport_AddModuleObject
msg331745 - (view) Author: Aaqa Ishtyaq (aaqaishtyaq) * Date: 2018-12-13 07:51
Hi, I want to work on this issue, but I'm confused about how to apply to PyImport_AddModuleObject.

I was also going through c_annotations.py[1].

[1] https://github.com/python/cpython/blob/master/Doc/tools/extensions/c_annotations.py
msg331746 - (view) Author: Ammar Askar (ammar2) * (Python committer) Date: 2018-12-13 08:04
A good place to start might be to search for a function that says it returns a borrowed reference in the source tree. For example, "PyImport_AddModule" says it returns a borrowed reference. 

In the search you'll find the relevant file here:

https://github.com/python/cpython/blob/e42b705188271da108de42b55d9344642170aa2b/Doc/data/refcounts.dat#L569
msg331752 - (view) Author: Aaqa Ishtyaq (aaqaishtyaq) * Date: 2018-12-13 09:54
I was going through the source code to understand what is going on, but I can't find any function that returns a borrowed reference for 'PyImport_AddModuleObject'.

Also, should I need to familiar with these macros and how they work?
https://docs.python.org/3/c-api/refcounting.html
msg331754 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-12-13 10:26
Information about borrowed references is taken from Doc/data/refcounts.dat.
msg332010 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-12-17 15:30
New changeset bdabb0737c631835b246c9823852d20331243315 by Serhiy Storchaka in branch 'master':
bpo-35475: Add more PyImport* functions in refcounts.dat. (GH-11142)
https://github.com/python/cpython/commit/bdabb0737c631835b246c9823852d20331243315
msg332013 - (view) Author: miss-islington (miss-islington) Date: 2018-12-17 15:48
New changeset 605ef6e534f05925ff826f65518abf163ed3900a by Miss Islington (bot) in branch '3.7':
bpo-35475: Add more PyImport* functions in refcounts.dat. (GH-11142)
https://github.com/python/cpython/commit/605ef6e534f05925ff826f65518abf163ed3900a
msg332258 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2018-12-20 20:50
New changeset 75f187478603de33c15f501a947207bfe8ba833f by Ned Deily (Miss Islington (bot)) in branch '3.6':
bpo-35475: Add more PyImport* functions in refcounts.dat. (GH-11142) (GH-11199)
https://github.com/python/cpython/commit/75f187478603de33c15f501a947207bfe8ba833f
History
Date User Action Args
2022-04-11 14:59:09adminsetgithub: 79656
2018-12-20 20:50:02ned.deilysetnosy: + ned.deily
messages: + msg332258
2018-12-19 09:27:20serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2018-12-17 15:48:31miss-islingtonsetnosy: + miss-islington
messages: + msg332013
2018-12-17 15:30:36miss-islingtonsetpull_requests: + pull_request10438
2018-12-17 15:30:20miss-islingtonsetpull_requests: + pull_request10437
2018-12-17 15:30:06serhiy.storchakasetmessages: + msg332010
2018-12-13 10:26:37serhiy.storchakasetmessages: + msg331754
2018-12-13 10:24:05serhiy.storchakasetkeywords: + patch
stage: needs patch -> patch review
pull_requests: + pull_request10372
2018-12-13 10:19:32serhiy.storchakasetassignee: docs@python -> serhiy.storchaka

nosy: + serhiy.storchaka
2018-12-13 09:54:31aaqaishtyaqsetmessages: + msg331752
2018-12-13 08:04:17ammar2setnosy: + ammar2
messages: + msg331746
2018-12-13 07:51:23aaqaishtyaqsetnosy: + aaqaishtyaq
messages: + msg331745
2018-12-12 19:11:41eric.snowcreate