bpo-36405: IDLE - Restore __main__ and add tests (#12518)

Fix error in commit 2b75155 noticed by Serhiy Storchaka.
This commit is contained in:
Terry Jan Reedy 2019-03-24 17:12:28 -04:00 committed by GitHub
parent 6661c1720e
commit 0fe4513d9a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 10 deletions

View file

@ -3,6 +3,7 @@
Either on demand or after a user-selected delay after a key character,
pop up a list of candidates.
"""
import __main__
import os
import string
import sys
@ -181,7 +182,8 @@ class AutoComplete:
else:
if mode == COMPLETE_ATTRIBUTES:
if what == "":
namespace = {**__builtins__.__dict__, **globals()}
namespace = {**__main__.__builtins__.__dict__,
**__main__.__dict__}
bigl = eval("dir()", namespace)
bigl.sort()
if "__all__" in bigl:
@ -216,8 +218,8 @@ class AutoComplete:
return smalll, bigl
def get_entity(self, name):
"Lookup name in a namespace spanning sys.modules and globals()."
return eval(name, {**sys.modules, **globals()})
"Lookup name in a namespace spanning sys.modules and __main.dict__."
return eval(name, {**sys.modules, **__main__.__dict__})
AutoComplete.reload()