bpo-36429: Fix starting IDLE with pyshell (#12548) · python/cpython@6a258c8 · GitHub
Skip to content

Commit 6a258c8

Browse files
authored
bpo-36429: Fix starting IDLE with pyshell (#12548)
Add idlelib.pyshell alias at top; remove pyshell alias at bottom. Remove obsolete __name__=='__main__' command.
1 parent 6da20a4 commit 6a258c8

3 files changed

Lines changed: 14 additions & 5 deletions

File tree

Lib/idlelib/NEWS.txt

Lines changed: 9 additions & 0 deletions

Lib/idlelib/pyshell.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#! /usr/bin/env python3
22

33
import sys
4+
if __name__ == "__main__":
5+
sys.modules['idlelib.pyshell'] = sys.modules['__main__']
46

57
try:
68
from tkinter import *
@@ -416,10 +418,7 @@ def build_subprocess_arglist(self):
416418
# run from the IDLE source directory.
417419
del_exitf = idleConf.GetOption('main', 'General', 'delete-exitfunc',
418420
default=False, type='bool')
419-
if __name__ == 'idlelib.pyshell':
420-
command = "__import__('idlelib.run').run.main(%r)" % (del_exitf,)
421-
else:
422-
command = "__import__('run').main(%r)" % (del_exitf,)
421+
command = "__import__('idlelib.run').run.main(%r)" % (del_exitf,)
423422
return [sys.executable] + w + ["-c", command, str(self.port)]
424423

425424
def start_subprocess(self):
@@ -1574,7 +1573,6 @@ def main():
15741573
capture_warnings(False)
15751574

15761575
if __name__ == "__main__":
1577-
sys.modules['pyshell'] = sys.modules['__main__']
15781576
main()
15791577

15801578
capture_warnings(False) # Make sure turned off; see issue 18081
Lines changed: 2 additions & 0 deletions

0 commit comments

Comments
 (0)