Title: Remove useless check in subprocess
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.8
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: qingyunha, serhiy.storchaka
Priority: normal Keywords:

Created on 2018-05-16 13:21 by qingyunha, last changed 2018-05-17 14:28 by serhiy.storchaka. This issue is now closed.

Messages (4)
msg316804 - (view) Author: TaoQingyun (qingyunha) * Date: 2018-05-16 13:21
diff --git a/Lib/ b/Lib/
index bafb501fcf..4a0bb33978 100644
--- a/Lib/
+++ b/Lib/
@@ -766,7 +766,7 @@ class Popen(object):
                   ResourceWarning, source=self)
         # In case the child hasn't been waited on, check if it's done.
-        if self.returncode is None and _active is not None:
+        if self.returncode is None:
             # Child is still running, keep us alive until we can wait on it.

the `_active` is initialized with [] at the beginning of the module.
msg316806 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-05-16 13:42
It is reset to None at the interpreter shutdown stage. This check was added intentionally.
msg316933 - (view) Author: TaoQingyun (qingyunha) * Date: 2018-05-17 14:09
I can't find the reset code, could you give me a link? Thanks.
msg316937 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-05-17 14:28
It is in PyImport_Cleanup() in Python/import.c. Search PyObject_SetItem(modules, name, Py_None).

If you will run Python with the -v option you will see numerous messages "# cleanup[2] removing ..." emitted on stderr.
Date User Action Args
2018-05-17 14:28:11serhiy.storchakasetmessages: + msg316937
2018-05-17 14:09:55qingyunhasetmessages: + msg316933
2018-05-16 13:42:42serhiy.storchakasetstatus: open -> closed

nosy: + serhiy.storchaka
messages: + msg316806

resolution: not a bug
stage: resolved
2018-05-16 13:21:21qingyunhacreate