From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Wed, 27 Mar 2019 00:19:23 +0000 (-0700) Subject: bpo-36429: Fix starting IDLE with pyshell (GH-12548) X-Git-Tag: v3.7.4rc1~290 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=23eb816399ac7482d2bd7d50814b19a3db52e7d4;p=thirdparty%2FPython%2Fcpython.git bpo-36429: Fix starting IDLE with pyshell (GH-12548) Add idlelib.pyshell alias at top; remove pyshell alias at bottom. Remove obsolete __name__=='__main__' command. (cherry picked from commit 6a258c88906a7e8acde455ee2acb78b6f315ea0b) Co-authored-by: Terry Jan Reedy --- diff --git a/Lib/idlelib/NEWS.txt b/Lib/idlelib/NEWS.txt index f136810e7a86..6340e19bb80b 100644 --- a/Lib/idlelib/NEWS.txt +++ b/Lib/idlelib/NEWS.txt @@ -3,6 +3,15 @@ Released on 2019-??-?? ====================================== +bpo-36429: Fix starting IDLE with pyshell. +Add idlelib.pyshell alias at top; remove pyshell alias at bottom. +Remove obsolete __name__=='__main__' command. + +bpo-30348: Increase test coverage of idlelib.autocomplete by 30%. +Patch by Louie Lu. + +bpo-23205: Add tests and refactor grep's findfiles. + bpo-36405: Use dict unpacking in idlelib. bpo-36396: Remove fgBg param of idlelib.config.GetHighlight(). diff --git a/Lib/idlelib/pyshell.py b/Lib/idlelib/pyshell.py index 11bafdb49aaa..2de42658b01c 100755 --- a/Lib/idlelib/pyshell.py +++ b/Lib/idlelib/pyshell.py @@ -1,6 +1,8 @@ #! /usr/bin/env python3 import sys +if __name__ == "__main__": + sys.modules['idlelib.pyshell'] = sys.modules['__main__'] try: from tkinter import * @@ -416,10 +418,7 @@ class ModifiedInterpreter(InteractiveInterpreter): # run from the IDLE source directory. del_exitf = idleConf.GetOption('main', 'General', 'delete-exitfunc', default=False, type='bool') - if __name__ == 'idlelib.pyshell': - command = "__import__('idlelib.run').run.main(%r)" % (del_exitf,) - else: - command = "__import__('run').main(%r)" % (del_exitf,) + command = "__import__('idlelib.run').run.main(%r)" % (del_exitf,) return [sys.executable] + w + ["-c", command, str(self.port)] def start_subprocess(self): @@ -1574,7 +1573,6 @@ def main(): capture_warnings(False) if __name__ == "__main__": - sys.modules['pyshell'] = sys.modules['__main__'] main() capture_warnings(False) # Make sure turned off; see issue 18081 diff --git a/Misc/NEWS.d/next/IDLE/2019-03-26-00-09-50.bpo-36429.w-jL2e.rst b/Misc/NEWS.d/next/IDLE/2019-03-26-00-09-50.bpo-36429.w-jL2e.rst new file mode 100644 index 000000000000..1d6bb1a587b5 --- /dev/null +++ b/Misc/NEWS.d/next/IDLE/2019-03-26-00-09-50.bpo-36429.w-jL2e.rst @@ -0,0 +1,2 @@ +Fix starting IDLE with pyshell. Add idlelib.pyshell alias at top; remove +pyshell alias at bottom. Remove obsolete __name__=='__main__' command.