Issue 30166: Import command-line parsing modules only when needed (original) (raw)

Issue30166

Created on 2017-04-26 08:34 by serhiy.storchaka, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 1293 merged serhiy.storchaka,2017-04-26 08:36
PR 2098 merged terry.reedy,2017-06-11 04:16
Messages (5)
msg292319 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-04-26 08:34
Berker suggested to move this part from to its own PR. When the file can be imported as a module and run as a script it is worth to make command-line parsing modules (getopt, optparse, argparse) be imported only when they are used, i.e. when the file is ran as a script. Most of the stdlib modules already do this. Proposed patch moves imports of command-line parsing modules and some other modules used only when the module is ran to the main() function or to the branch executed only if __name__ == "__main__". It doesn't change scripts and files that are purposed to be used only for running (__main__.py, main.py).
msg292961 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-05-04 05:17
New changeset 7e4db2f253c555568d56177c2fd083bcf8f88d34 by Serhiy Storchaka in branch 'master': bpo-30166: Import command-line parsing modules only when needed. (#1293) https://github.com/python/cpython/commit/7e4db2f253c555568d56177c2fd083bcf8f88d34
msg292965 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-05-04 06:16
I want to backport the idlelib.pyshell change. I have been told that even a partial backport, even if done by hand, is a backport and the result a cherry-pick.
msg295687 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-06-11 04:34
New changeset c0ef607c52e58e94693fbedb27f2813bc3fed8fa by terryjreedy in branch '3.6': [3.6] bpo-30166: backport pyshell changes (GH 1293) (#2098) https://github.com/python/cpython/commit/c0ef607c52e58e94693fbedb27f2813bc3fed8fa
msg377159 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2020-09-19 11:33
Looks like the backport was done and this issue can be closed.
History
Date User Action Args
2022-04-11 14:58:45 admin set github: 74352
2020-09-19 15:36:00 serhiy.storchaka set status: open -> closedstage: backport needed -> resolved
2020-09-19 11:33:58 iritkatriel set nosy: + iritkatrielmessages: +
2017-06-11 04:34:22 terry.reedy set messages: +
2017-06-11 04:16:24 terry.reedy set pull_requests: + <pull%5Frequest2154>
2017-05-04 06:16:19 terry.reedy set status: closed -> openassignee: serhiy.storchaka -> terry.reedyversions: + Python 3.6, - Python 3.7nosy: + terry.reedymessages: + stage: resolved -> backport needed
2017-05-04 05:53:31 serhiy.storchaka set status: open -> closedassignee: serhiy.storchakaresolution: fixedstage: patch review -> resolved
2017-05-04 05:17:50 serhiy.storchaka set messages: +
2017-04-26 08:38:00 serhiy.storchaka set nosy: + bethard, aronacher, berker.peksag
2017-04-26 08:36:46 serhiy.storchaka set pull_requests: + <pull%5Frequest1400>
2017-04-26 08:34:19 serhiy.storchaka create