======================================
+bpo-36405: Use dict unpacking in idlelib and remove unneeded __main__ imports.
+
bpo-36396: Remove fgBg param of idlelib.config.GetHighlight().
This param was only used twice and changed the return type.
from idlelib import autocomplete_w
from idlelib.config import idleConf
from idlelib.hyperparser import HyperParser
-import __main__
# This string includes all chars that may be in an identifier.
# TODO Update this here and elsewhere.
else:
if mode == COMPLETE_ATTRIBUTES:
if what == "":
- namespace = __main__.__dict__.copy()
- namespace.update(__main__.__builtins__.__dict__)
+ namespace = {**__builtins__.__dict__, **globals()}
bigl = eval("dir()", namespace)
bigl.sort()
if "__all__" in bigl:
return smalll, bigl
def get_entity(self, name):
- """Lookup name in a namespace spanning sys.modules and __main.dict__"""
- namespace = sys.modules.copy()
- namespace.update(__main__.__dict__)
- return eval(name, namespace)
+ "Lookup name in a namespace spanning sys.modules and globals()."
+ return eval(name, {**sys.modules, **globals()})
AutoComplete.reload()
from idlelib import calltip_w
from idlelib.hyperparser import HyperParser
-import __main__
class Calltip:
def get_entity(expression):
"""Return the object corresponding to expression evaluated
- in a namespace spanning sys.modules and __main.dict__.
+ in a namespace spanning sys.modules and globals().
"""
if expression:
- namespace = sys.modules.copy()
- namespace.update(__main__.__dict__)
+ namespace = {**sys.modules, **globals()}
try:
- return eval(expression, namespace)
+ return eval(expression, namespace) # Only protect user code.
except BaseException:
# An uncaught exception closes idle, and eval can raise any
# exception, especially if user classes are involved.