bpo-36405: Use dict unpacking in idlelib (GH-12507)
Remove now unneeded imports.
(cherry picked from commit 2b75155590eb42d25e474b776ee9fdcc4b3dc840)
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
diff --git a/Lib/idlelib/calltip.py b/Lib/idlelib/calltip.py
index 2a9a131..4b78917 100644
--- a/Lib/idlelib/calltip.py
+++ b/Lib/idlelib/calltip.py
@@ -12,7 +12,6 @@
from idlelib import calltip_w
from idlelib.hyperparser import HyperParser
-import __main__
class Calltip:
@@ -100,13 +99,12 @@
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.