Skip to content

Commit 6fa5bdc

Browse files
committed
Issue #24225: Within idlelib files, update idlelib module names.
This follows the previous patch that changed idlelib file names. Class names that matched old module names are not changed. Change idlelib imports in turtledemo.__main__. Exception: config-extensions.def. Previously, extension section names, file names, and class names had to match. Changing section names would create cross-version conflicts in config-extensions.cfg (user customizations). Instead map old names to new file names at point of import in editor.EditorWindow.load_extension. Patch extensively tested with test_idle, idle_test.htest.py, a custom import-all test, running IDLE in a console to catch messages, and testing each menu item. Based on a patch by Al Sweigart.
1 parent 0d9220e commit 6fa5bdc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+378
-360
lines changed

Lib/idlelib/__main__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
44
Run IDLE as python -m idlelib
55
"""
6-
import idlelib.PyShell
7-
idlelib.PyShell.main()
6+
import idlelib.pyshell
7+
idlelib.pyshell.main()
88
# This file does not work for 2.7; See issue 24212.

Lib/idlelib/autocomplete.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""AutoComplete.py - An IDLE extension for automatically completing names.
1+
"""autocomplete.py - An IDLE extension for automatically completing names.
22
33
This extension can complete either attribute names of file names. It can pop
44
a window with all available names, for the user to select from.
@@ -7,16 +7,16 @@
77
import sys
88
import string
99

10-
from idlelib.configHandler import idleConf
10+
from idlelib.config import idleConf
1111

1212
# This string includes all chars that may be in an identifier
1313
ID_CHARS = string.ascii_letters + string.digits + "_"
1414

1515
# These constants represent the two different types of completions
1616
COMPLETE_ATTRIBUTES, COMPLETE_FILES = range(1, 2+1)
1717

18-
from idlelib import AutoCompleteWindow
19-
from idlelib.HyperParser import HyperParser
18+
from idlelib import autocomplete_w
19+
from idlelib.hyperparser import HyperParser
2020

2121
import __main__
2222

@@ -49,7 +49,7 @@ def __init__(self, editwin=None):
4949
self._delayed_completion_index = None
5050

5151
def _make_autocomplete_window(self):
52-
return AutoCompleteWindow.AutoCompleteWindow(self.text)
52+
return autocomplete_w.AutoCompleteWindow(self.text)
5353

5454
def _remove_autocomplete_window(self, event=None):
5555
if self.autocompletewindow:

Lib/idlelib/autocomplete_w.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
"""
2-
An auto-completion window for IDLE, used by the AutoComplete extension
2+
An auto-completion window for IDLE, used by the autocomplete extension
33
"""
44
from tkinter import *
5-
from idlelib.MultiCall import MC_SHIFT
6-
from idlelib.AutoComplete import COMPLETE_FILES, COMPLETE_ATTRIBUTES
5+
from idlelib.multicall import MC_SHIFT
6+
from idlelib.autocomplete import COMPLETE_FILES, COMPLETE_ATTRIBUTES
77

88
HIDE_VIRTUAL_EVENT_NAME = "<<autocompletewindow-hide>>"
99
HIDE_SEQUENCES = ("<FocusOut>", "<ButtonPress>")
@@ -34,8 +34,8 @@ def __init__(self, widget):
3434
self.completions = None
3535
# A list with more completions, or None
3636
self.morecompletions = None
37-
# The completion mode. Either AutoComplete.COMPLETE_ATTRIBUTES or
38-
# AutoComplete.COMPLETE_FILES
37+
# The completion mode. Either autocomplete.COMPLETE_ATTRIBUTES or
38+
# autocomplete.COMPLETE_FILES
3939
self.mode = None
4040
# The current completion start, on the text box (a string)
4141
self.start = None

Lib/idlelib/browser.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
import sys
1515
import pyclbr
1616

17-
from idlelib import PyShell
18-
from idlelib.WindowList import ListedToplevel
19-
from idlelib.TreeWidget import TreeNode, TreeItem, ScrolledCanvas
20-
from idlelib.configHandler import idleConf
17+
from idlelib import pyshell
18+
from idlelib.windows import ListedToplevel
19+
from idlelib.tree import TreeNode, TreeItem, ScrolledCanvas
20+
from idlelib.config import idleConf
2121

2222
file_open = None # Method...Item and Class...Item use this.
23-
# Normally PyShell.flist.open, but there is no PyShell.flist for htest.
23+
# Normally pyshell.flist.open, but there is no pyshell.flist for htest.
2424

2525
class ClassBrowser:
2626

@@ -32,7 +32,7 @@ def __init__(self, flist, name, path, _htest=False):
3232
"""
3333
global file_open
3434
if not _htest:
35-
file_open = PyShell.flist.open
35+
file_open = pyshell.flist.open
3636
self.name = name
3737
self.file = os.path.join(path[0], self.name + ".py")
3838
self._htest = _htest
@@ -95,7 +95,7 @@ def OnDoubleClick(self):
9595
return
9696
if not os.path.exists(self.file):
9797
return
98-
PyShell.flist.open(self.file)
98+
pyshell.flist.open(self.file)
9999

100100
def IsExpandable(self):
101101
return os.path.normcase(self.file[-3:]) == ".py"
@@ -226,7 +226,7 @@ def _class_browser(parent): #Wrapper for htest
226226
file = sys.argv[0]
227227
dir, file = os.path.split(file)
228228
name = os.path.splitext(file)[0]
229-
flist = PyShell.PyShellFileList(parent)
229+
flist = pyshell.PyShellFileList(parent)
230230
global file_open
231231
file_open = flist.open
232232
ClassBrowser(flist, name, [dir], _htest=True)

Lib/idlelib/calltip_w.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""A CallTip window class for Tkinter/IDLE.
22
3-
After ToolTip.py, which uses ideas gleaned from PySol
4-
Used by the CallTips IDLE extension.
3+
After tooltip.py, which uses ideas gleaned from PySol
4+
Used by the calltips IDLE extension.
55
"""
66
from tkinter import Toplevel, Label, LEFT, SOLID, TclError
77

Lib/idlelib/calltips.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""CallTips.py - An IDLE Extension to Jog Your Memory
1+
"""calltips.py - An IDLE Extension to Jog Your Memory
22
33
Call Tips are floating windows which display function, class, and method
44
parameter and docstring information when you type an opening parenthesis, and
@@ -12,8 +12,8 @@
1212
import textwrap
1313
import types
1414

15-
from idlelib import CallTipWindow
16-
from idlelib.HyperParser import HyperParser
15+
from idlelib import calltip_w
16+
from idlelib.hyperparser import HyperParser
1717

1818
class CallTips:
1919

@@ -37,7 +37,7 @@ def close(self):
3737

3838
def _make_tk_calltip_window(self):
3939
# See __init__ for usage
40-
return CallTipWindow.CallTip(self.text)
40+
return calltip_w.CallTip(self.text)
4141

4242
def _remove_calltip_window(self, event=None):
4343
if self.active_calltip:

Lib/idlelib/codecontext.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
"""CodeContext - Extension to display the block context above the edit window
1+
"""codecontext - Extension to display the block context above the edit window
22
33
Once code has scrolled off the top of a window, it can be difficult to
44
determine which block you are in. This extension implements a pane at the top
55
of each IDLE edit window which provides block structure hints. These hints are
66
the lines which contain the block opening keywords, e.g. 'if', for the
77
enclosing block. The number of hint lines is determined by the numlines
8-
variable in the CodeContext section of config-extensions.def. Lines which do
8+
variable in the codecontext section of config-extensions.def. Lines which do
99
not open blocks are not shown in the context hints pane.
1010
1111
"""
1212
import tkinter
1313
from tkinter.constants import TOP, LEFT, X, W, SUNKEN
1414
import re
1515
from sys import maxsize as INFINITY
16-
from idlelib.configHandler import idleConf
16+
from idlelib.config import idleConf
1717

1818
BLOCKOPENERS = {"class", "def", "elif", "else", "except", "finally", "for",
1919
"if", "try", "while", "with"}

Lib/idlelib/colorizer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
import re
33
import keyword
44
import builtins
5-
from idlelib.Delegator import Delegator
6-
from idlelib.configHandler import idleConf
5+
from idlelib.delegator import Delegator
6+
from idlelib.config import idleConf
77

88
DEBUG = False
99

@@ -235,7 +235,7 @@ def removecolors(self):
235235

236236
def _color_delegator(parent): # htest #
237237
from tkinter import Toplevel, Text
238-
from idlelib.Percolator import Percolator
238+
from idlelib.percolator import Percolator
239239

240240
top = Toplevel(parent)
241241
top.title("Test ColorDelegator")

Lib/idlelib/config.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
and if a file becomes empty, it will be deleted.
88
99
The contents of the user files may be altered using the Options/Configure IDLE
10-
menu to access the configuration GUI (configDialog.py), or manually.
10+
menu to access the configuration GUI (configdialog.py), or manually.
1111
1212
Throughout this module there is an emphasis on returning useable defaults
1313
when a problem occurs in returning a requested configuration value back to
@@ -230,7 +230,7 @@ def GetOption(self, configType, section, option, default=None, type=None,
230230
return self.userCfg[configType].Get(section, option,
231231
type=type, raw=raw)
232232
except ValueError:
233-
warning = ('\n Warning: configHandler.py - IdleConf.GetOption -\n'
233+
warning = ('\n Warning: config.py - IdleConf.GetOption -\n'
234234
' invalid %r value for configuration option %r\n'
235235
' from section %r: %r' %
236236
(type, option, section,
@@ -247,7 +247,7 @@ def GetOption(self, configType, section, option, default=None, type=None,
247247
pass
248248
#returning default, print warning
249249
if warn_on_default:
250-
warning = ('\n Warning: configHandler.py - IdleConf.GetOption -\n'
250+
warning = ('\n Warning: config.py - IdleConf.GetOption -\n'
251251
' problem retrieving configuration option %r\n'
252252
' from section %r.\n'
253253
' returning default value: %r' %
@@ -358,7 +358,7 @@ def GetThemeDict(self, type, themeName):
358358
for element in theme:
359359
if not cfgParser.has_option(themeName, element):
360360
# Print warning that will return a default color
361-
warning = ('\n Warning: configHandler.IdleConf.GetThemeDict'
361+
warning = ('\n Warning: config.IdleConf.GetThemeDict'
362362
' -\n problem retrieving theme element %r'
363363
'\n from theme %r.\n'
364364
' returning default color: %r' %
@@ -644,7 +644,7 @@ def GetCoreKeys(self, keySetName=None):
644644
if binding:
645645
keyBindings[event] = binding
646646
else: #we are going to return a default, print warning
647-
warning=('\n Warning: configHandler.py - IdleConf.GetCoreKeys'
647+
warning=('\n Warning: config.py - IdleConf.GetCoreKeys'
648648
' -\n problem retrieving key binding for event %r'
649649
'\n from key set %r.\n'
650650
' returning default value: %r' %

Lib/idlelib/config_sec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
Dialog that allows user to specify a new config file section name.
33
Used to get new highlight theme and keybinding set names.
4-
The 'return value' for the dialog, used two placed in configDialog.py,
4+
The 'return value' for the dialog, used two placed in configdialog.py,
55
is the .result attribute set in the Ok and Cancel methods.
66
"""
77
from tkinter import *

0 commit comments

Comments
 (0)