======================================
-bpo-36405: Use dict unpacking in idlelib and remove unneeded __main__ imports.
+bpo-36405: Use dict unpacking in idlelib.
bpo-36396: Remove fgBg param of idlelib.config.GetHighlight().
This param was only used twice and changed the return type.
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
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:
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()
parameter and docstring information when you type an opening parenthesis, and
which disappear when you type a closing parenthesis.
"""
+import __main__
import inspect
import re
import sys
def get_entity(expression):
"""Return the object corresponding to expression evaluated
- in a namespace spanning sys.modules and globals().
+ in a namespace spanning sys.modules and __main.dict__.
"""
if expression:
- namespace = {**sys.modules, **globals()}
+ namespace = {**sys.modules, **__main__.__dict__}
try:
return eval(expression, namespace) # Only protect user code.
except BaseException:
import unittest
from test.support import requires
from tkinter import Tk, Text
+import __main__
import idlelib.autocomplete as ac
import idlelib.autocomplete_w as acw
del cls.root
def setUp(self):
- self.editor.text.delete('1.0', 'end')
+ self.text.delete('1.0', 'end')
self.autocomplete = ac.AutoComplete(self.editor)
def test_init(self):
# a small list containing non-private variables.
# For file completion, a large list containing all files in the path,
# and a small list containing files that do not start with '.'
- pass
+ small, large = self.autocomplete.fetch_completions(
+ '', ac.COMPLETE_ATTRIBUTES)
+ self.assertLess(len(small), len(large))
+ if __main__.__file__ != ac.__file__:
+ self.assertNotIn('AutoComplete', small) # See issue 36405.
def test_get_entity(self):
# Test that a name is in the namespace of sys.modules and
# __main__.__dict__
- pass
+ self.assertEqual(self.autocomplete.get_entity('int'), int)
if __name__ == '__main__':
-Use dict unpacking in idlelib and remove unneeded __main__ imports.
+Use dict unpacking in idlelib.