Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3805321

Browse files
committed
Merged revisions 59465-59487 via svnmerge from
svn+ssh://[email protected]/python/trunk ........ r59467 | georg.brandl | 2007-12-11 17:32:49 +0100 (Tue, 11 Dec 2007) | 2 lines Add another GHOP contributor. ........ r59468 | kurt.kaiser | 2007-12-11 20:35:12 +0100 (Tue, 11 Dec 2007) | 3 lines IDLE_tabbedpages.071101.patch Tal Einat Cosmetic changes, one bug. Remove tabpage.py, replaced by tabbedpages.py ........ r59471 | gerhard.haering | 2007-12-11 22:07:40 +0100 (Tue, 11 Dec 2007) | 9 lines Forward-port of commit 59184. - Backported a workaround for a bug in SQLite 3.2.x/3.3.x versions where a statement recompilation with no bound parameters lead to a segfault - Backported a fix necessary because of an SQLite API change in version 3.5. This prevents segfaults when executing empty queries, like our test suite does ........ r59475 | christian.heimes | 2007-12-12 19:09:06 +0100 (Wed, 12 Dec 2007) | 1 line Fixed a nasty problem in the xxmodule.c ........ r59478 | raymond.hettinger | 2007-12-13 01:08:37 +0100 (Thu, 13 Dec 2007) | 1 line Fix bug 1604. deque.__init__() did not clear existing contents like list.__init__. Not a backport candidate. ........ r59480 | alexandre.vassalotti | 2007-12-13 18:58:23 +0100 (Thu, 13 Dec 2007) | 2 lines Fix issue #1313119: urlparse "caches" parses regardless of encoding ........ r59482 | christian.heimes | 2007-12-13 20:23:16 +0100 (Thu, 13 Dec 2007) | 1 line Fixed bug #1613: Makefile's VPATH feature is broken ........ r59484 | guido.van.rossum | 2007-12-13 21:50:10 +0100 (Thu, 13 Dec 2007) | 3 lines Patch #1608. Someone with access to autoconf 2.61 or higher needs to run it and check in the resulting configure file. ........ r59485 | thomas.heller | 2007-12-13 22:20:29 +0100 (Thu, 13 Dec 2007) | 1 line Ran autoconf. ........ r59486 | raymond.hettinger | 2007-12-13 23:55:52 +0100 (Thu, 13 Dec 2007) | 1 line Simplify implementation of __replace__() ........ r59487 | raymond.hettinger | 2007-12-14 00:52:59 +0100 (Fri, 14 Dec 2007) | 1 line Small speedup ........
1 parent 8a78cad commit 3805321

16 files changed

Lines changed: 86 additions & 166 deletions

File tree

Doc/ACKS.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ [email protected]), and we'll be glad to correct the problem.
136136
* Tomas Oppelstrup
137137
* Denis S. Otkidach
138138
* Zooko O'Whielacronx
139+
* Shriphani Palakodety
139140
* William Park
140141
* Joonas Paalasmaa
141142
* Harri Pasanen

Doc/library/collections.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ Example::
429429
return dict(zip(('x', 'y'), self))
430430
def __replace__(self, **kwds):
431431
'Return a new Point object replacing specified fields with new values'
432-
return Point(**dict(zip(('x', 'y'), self) + kwds.items()))
432+
return Point(**dict(zip(('x', 'y'), self), **kwds))
433433
x = property(itemgetter(0))
434434
y = property(itemgetter(1))
435435

Lib/collections.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from _collections import deque, defaultdict
44
from operator import itemgetter as _itemgetter
5+
from itertools import izip as _izip
56
from keyword import iskeyword as _iskeyword
67
import sys as _sys
78

@@ -70,14 +71,14 @@ def __asdict__(self, dict=dict, zip=zip):
7071
return dict(zip(%(field_names)r, self))
7172
def __replace__(self, **kwds):
7273
'Return a new %(typename)s object replacing specified fields with new values'
73-
return %(typename)s(**dict(list(zip(%(field_names)r, self)) + list(kwds.items()))) \n''' % locals()
74+
return %(typename)s(**dict(zip(%(field_names)r, self), **kwds)) \n''' % locals()
7475
for i, name in enumerate(field_names):
7576
template += ' %s = property(itemgetter(%d))\n' % (name, i)
7677
if verbose:
7778
print(template)
7879

7980
# Execute the template string in a temporary namespace
80-
namespace = dict(itemgetter=_itemgetter)
81+
namespace = dict(itemgetter=_itemgetter, zip=_izip)
8182
try:
8283
exec(template, namespace)
8384
except SyntaxError as e:

Lib/distutils/sysconfig.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
# building an extension with an un-installed Python, so we use
3333
# different (hard-wired) directories.
3434
python_build = os.path.isfile(os.path.join(project_base, "Modules",
35-
"Setup.dist"))
35+
"Setup.local"))
3636

3737
def get_python_version():
3838
"""Return a string containing the major and minor Python version,

Lib/idlelib/tabbedpages.py

Lines changed: 47 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
Classes exported:
66
TabbedPageSet -- A Tkinter implementation of a tabbed-page widget.
7-
TabBarSet -- A widget containing tabs (buttons) in one or more rows.
7+
TabSet -- A widget containing tabs (buttons) in one or more rows.
88
99
"""
1010
from Tkinter import *
@@ -13,7 +13,7 @@ class InvalidNameError(Exception): pass
1313
class AlreadyExistsError(Exception): pass
1414

1515

16-
class TabBarSet(Frame):
16+
class TabSet(Frame):
1717
"""A widget containing tabs (buttons) in one or more rows.
1818
1919
Only one tab may be selected at a time.
@@ -30,11 +30,11 @@ def __init__(self, page_set, select_command,
3030
3131
tabs -- A list of strings, the names of the tabs. Should be specified in
3232
the desired tab order. The first tab will be the default and first
33-
active tab. If tabs is None or empty, the TabBarSet will be initialized
33+
active tab. If tabs is None or empty, the TabSet will be initialized
3434
empty.
3535
3636
n_rows -- Number of rows of tabs to be shown. If n_rows <= 0 or is
37-
None, then the number of rows will be decided by TabBarSet. See
37+
None, then the number of rows will be decided by TabSet. See
3838
_arrange_tabs() for details.
3939
4040
max_tabs_per_row -- Used for deciding how many rows of tabs are needed,
@@ -76,15 +76,15 @@ def add_tab(self, tab_name):
7676
self._arrange_tabs()
7777

7878
def remove_tab(self, tab_name):
79-
"""Remove the tab with the name given in tab_name."""
79+
"""Remove the tab named <tab_name>"""
8080
if not tab_name in self._tab_names:
8181
raise KeyError("No such Tab: '%s" % page_name)
8282

8383
self._tab_names.remove(tab_name)
8484
self._arrange_tabs()
8585

86-
def select_tab(self, tab_name):
87-
"""Select the tab with the name given in tab_name."""
86+
def set_selected_tab(self, tab_name):
87+
"""Show the tab named <tab_name> as the selected one"""
8888
if tab_name == self._selected_tab:
8989
return
9090
if tab_name is not None and tab_name not in self._tabs:
@@ -111,21 +111,19 @@ def _add_tab_row(self, tab_names, expand_tabs):
111111

112112
tab_row = Frame(self)
113113
tab_row.pack(side=TOP, fill=X, expand=0)
114-
tab_row.tab_set = self
115114
self._tab_rows.append(tab_row)
116115

117116
for tab_name in tab_names:
118-
def tab_command(select_command=self.select_command,
119-
tab_name=tab_name):
120-
return select_command(tab_name)
121-
tab = TabBarSet.TabButton(tab_row, tab_name, tab_command)
117+
tab = TabSet.TabButton(tab_name, self.select_command,
118+
tab_row, self)
122119
if expand_tabs:
123120
tab.pack(side=LEFT, fill=X, expand=True)
124121
else:
125122
tab.pack(side=LEFT)
126123
self._tabs[tab_name] = tab
127124
self._tab2row[tab] = tab_row
128125

126+
# tab is the last one created in the above loop
129127
tab.is_last_in_row = True
130128

131129
def _reset_tab_rows(self):
@@ -158,8 +156,9 @@ def _arrange_tabs(self):
158156
# calculate the required number of rows
159157
n_rows = (len(self._tab_names) - 1) // self.max_tabs_per_row + 1
160158

161-
i = 0
159+
# not expanding the tabs with more than one row is very ugly
162160
expand_tabs = self.expand_tabs or n_rows > 1
161+
i = 0 # index in self._tab_names
163162
for row_index in range(n_rows):
164163
# calculate required number of tabs in this row
165164
n_tabs = (len(self._tab_names) - i - 1) // (n_rows - row_index) + 1
@@ -169,47 +168,60 @@ def _arrange_tabs(self):
169168

170169
# re-select selected tab so it is properly displayed
171170
selected = self._selected_tab
172-
self.select_tab(None)
171+
self.set_selected_tab(None)
173172
if selected in self._tab_names:
174-
self.select_tab(selected)
173+
self.set_selected_tab(selected)
175174

176175
class TabButton(Frame):
177176
"""A simple tab-like widget."""
178177

179178
bw = 2 # borderwidth
180179

181-
def __init__(self, tab_row, name, command):
180+
def __init__(self, name, select_command, tab_row, tab_set):
182181
"""Constructor arguments:
183182
184183
name -- The tab's name, which will appear in its button.
185184
186-
command -- The command to be called upon selection of the tab. It
187-
is called with the tab's name as an argument.
185+
select_command -- The command to be called upon selection of the
186+
tab. It is called with the tab's name as an argument.
188187
189188
"""
190-
Frame.__init__(self, tab_row, borderwidth=self.bw)
191-
self.button = Radiobutton(self, text=name, command=command,
189+
Frame.__init__(self, tab_row, borderwidth=self.bw, relief=RAISED)
190+
191+
self.name = name
192+
self.select_command = select_command
193+
self.tab_set = tab_set
194+
self.is_last_in_row = False
195+
196+
self.button = Radiobutton(
197+
self, text=name, command=self._select_event,
192198
padx=5, pady=1, takefocus=FALSE, indicatoron=FALSE,
193199
highlightthickness=0, selectcolor='', borderwidth=0)
194200
self.button.pack(side=LEFT, fill=X, expand=True)
195201

196-
self.tab_set = tab_row.tab_set
197-
198-
self.is_last_in_row = False
199-
200202
self._init_masks()
201203
self.set_normal()
202204

205+
def _select_event(self, *args):
206+
"""Event handler for tab selection.
207+
208+
With TabbedPageSet, this calls TabbedPageSet.change_page, so that
209+
selecting a tab changes the page.
210+
211+
Note that this does -not- call set_selected -- it will be called by
212+
TabSet.set_selected_tab, which should be called when whatever the
213+
tabs are related to changes.
214+
215+
"""
216+
self.select_command(self.name)
217+
return
218+
203219
def set_selected(self):
204220
"""Assume selected look"""
205-
for widget in self, self.mskl.ml, self.mskr.mr:
206-
widget.config(relief=RAISED)
207221
self._place_masks(selected=True)
208222

209223
def set_normal(self):
210224
"""Assume normal look"""
211-
for widget in self, self.mskl.ml, self.mskr.mr:
212-
widget.config(relief=RAISED)
213225
self._place_masks(selected=False)
214226

215227
def _init_masks(self):
@@ -351,8 +363,8 @@ def __init__(self, parent, page_names=None, page_class=PageLift,
351363
and first active page. If page_names is None or empty, the
352364
TabbedPageSet will be initialized empty.
353365
354-
n_rows, max_tabs_per_row -- Parameters for the TabBarSet which will
355-
manage the tabs. See TabBarSet's docs for details.
366+
n_rows, max_tabs_per_row -- Parameters for the TabSet which will
367+
manage the tabs. See TabSet's docs for details.
356368
357369
page_class -- Pages can be shown/hidden using three mechanisms:
358370
@@ -372,7 +384,7 @@ def __init__(self, parent, page_names=None, page_class=PageLift,
372384
TabbedPageSet to resize when the page is changed.
373385
374386
"""
375-
Frame.__init__(self, parent, kw)
387+
Frame.__init__(self, parent, **kw)
376388

377389
self.page_class = page_class
378390
self.pages = {}
@@ -390,9 +402,9 @@ def __init__(self, parent, page_names=None, page_class=PageLift,
390402
self.pages_frame.rowconfigure(0, weight=1)
391403

392404
# the order of the following commands is important
393-
self._tab_set = TabBarSet(self, self.change_page, n_rows=n_rows,
394-
max_tabs_per_row=max_tabs_per_row,
395-
expand_tabs=expand_tabs)
405+
self._tab_set = TabSet(self, self.change_page, n_rows=n_rows,
406+
max_tabs_per_row=max_tabs_per_row,
407+
expand_tabs=expand_tabs)
396408
if page_names:
397409
for name in page_names:
398410
self.add_page(name)
@@ -453,7 +465,7 @@ def change_page(self, page_name):
453465
self._current_page = page_name
454466
self.pages[page_name]._show()
455467

456-
self._tab_set.select_tab(page_name)
468+
self._tab_set.set_selected_tab(page_name)
457469

458470
if __name__ == '__main__':
459471
# test dialog

Lib/idlelib/tabpage.py

Lines changed: 0 additions & 113 deletions
This file was deleted.

Lib/test/test_deque.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ def __eq__(self, other):
2929
class TestBasic(unittest.TestCase):
3030

3131
def test_basics(self):
32-
d = deque(range(100))
33-
d.__init__(range(100, 200))
32+
d = deque(range(-5125, -5000))
33+
d.__init__(range(200))
3434
for i in range(200, 400):
3535
d.append(i)
3636
for i in reversed(range(-200, 0)):
@@ -433,8 +433,8 @@ def __iter__(self):
433433
class TestSubclass(unittest.TestCase):
434434

435435
def test_basics(self):
436-
d = Deque(range(100))
437-
d.__init__(range(100, 200))
436+
d = Deque(range(25))
437+
d.__init__(range(200))
438438
for i in range(200, 400):
439439
d.append(i)
440440
for i in reversed(range(-200, 0)):

Lib/test/test_urlparse.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,6 @@ def test_attributes_without_netloc(self):
287287
self.assertEqual(p.port, None)
288288
self.assertEqual(p.geturl(), uri)
289289

290-
291290
def test_main():
292291
test_support.run_unittest(UrlParseTestCase)
293292

0 commit comments

Comments
 (0)