New submission from Serhiy Storchaka <storchaka+cpyt...@gmail.com>:

There is a reference leak in import_add_module(). PyDict_GetItemWithError() 
returns a borrowed reference, but PyObject_GetItem() return a non-borrowed 
reference. If sys.modules is not a dict, there is a reference leak. 
import_add_module() and several other function which return a borrowed 
reference should be made returning a non-borrowed reference, because there are 
no guaranties that general mapping keeps reference to value.

It is still not guarantee correctness of PyImport_AddModuleObject().

----------
components: Interpreter Core
messages: 378384
nosy: brett.cannon, eric.snow, ncoghlan, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Refcount issues in import
type: resource usage
versions: Python 3.10, Python 3.9

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue41994>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to