Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions 2 Lib/idlelib/NEWS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Released on 2019-10-20?
======================================


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.

Expand Down
10 changes: 3 additions & 7 deletions 10 Lib/idlelib/autocomplete.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
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.
Expand Down Expand Up @@ -182,8 +181,7 @@ def fetch_completions(self, what, mode):
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:
Expand Down Expand Up @@ -218,10 +216,8 @@ def fetch_completions(self, what, mode):
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()
Expand Down
8 changes: 3 additions & 5 deletions 8 Lib/idlelib/calltip.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

from idlelib import calltip_w
from idlelib.hyperparser import HyperParser
import __main__


class Calltip:
Expand Down Expand Up @@ -100,13 +99,12 @@ def fetch_tip(self, expression):

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.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use dict unpacking in idlelib and remove unneeded __main__ imports.
Morty Proxy This is a proxified and sanitized view of the page, visit original site.