Author serhiy.storchaka
Recipients brett.cannon, eric.snow, ncoghlan, serhiy.storchaka
Date 2020-10-10.10:51:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1602327087.97.0.628811045218.issue41993@roundup.psfhosted.org>
In-reply-to
Content
There are several issues in remove_module() in Python/import.c.

1. PyMapping_HasKey() is used to determine if the module was in sys.modules before removing it. But it can return 0 not only when the key is absent in the mapping, but also when some exceptions was raised during checking (including MemoryError, KeybordInterraption and RecursionError). The corresponding exception will be silenced and the module will be left in sys.modules.

2. If PyMapping_DelItem() fails, a RuntimeError is raised. It is chained with the exception raised in PyMapping_DelItem(), but the original exception, raised before calling remove_module() will be lost.

3. There is a possible race condition between PyMapping_HasKey() and PyMapping_DelItem().
History
Date User Action Args
2020-10-10 10:51:28serhiy.storchakasetrecipients: + serhiy.storchaka, brett.cannon, ncoghlan, eric.snow
2020-10-10 10:51:27serhiy.storchakasetmessageid: <1602327087.97.0.628811045218.issue41993@roundup.psfhosted.org>
2020-10-10 10:51:27serhiy.storchakalinkissue41993 messages
2020-10-10 10:51:27serhiy.storchakacreate