bpo-36429: Fix starting IDLE with pyshell (#12548) · python/cpython@6a258c8 (original) (raw)

1

1

`#! /usr/bin/env python3

`

2

2

``

3

3

`import sys

`

``

4

`+

if name == "main":

`

``

5

`+

sys.modules['idlelib.pyshell'] = sys.modules['main']

`

4

6

``

5

7

`try:

`

6

8

`from tkinter import *

`

`@@ -416,10 +418,7 @@ def build_subprocess_arglist(self):

`

416

418

`# run from the IDLE source directory.

`

417

419

`del_exitf = idleConf.GetOption('main', 'General', 'delete-exitfunc',

`

418

420

`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,)

`

423

422

`return [sys.executable] + w + ["-c", command, str(self.port)]

`

424

423

``

425

424

`def start_subprocess(self):

`

`@@ -1574,7 +1573,6 @@ def main():

`

1574

1573

`capture_warnings(False)

`

1575

1574

``

1576

1575

`if name == "main":

`

1577

``

`-

sys.modules['pyshell'] = sys.modules['main']

`

1578

1576

`main()

`

1579

1577

``

1580

1578

`capture_warnings(False) # Make sure turned off; see issue 18081

`