8000 SF patch #701494: more apply removals · python/cpython@ff41c48 · GitHub
[go: up one dir, main page]

Skip to content

Commit ff41c48

Browse files
committed
SF patch #701494: more apply removals
1 parent 50c61d5 commit ff41c48

23 files changed

+2460
-2472
lines changed

Lib/compiler/transformer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def Node(*args):
7272
kind = args[0]
7373
if nodes.has_key(kind):
7474
try:
75-
return apply(nodes[kind], args[1:])
75+
return nodes[kind](*args[1:])
7676
except TypeError:
7777
print nodes[kind], len(args), args
7878
raise

Lib/curses/wrapper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def wrapper(func, *rest):
4141
except:
4242
pass
4343

44-
res = apply(func, (stdscr,) + rest)
44+
res = func(stdscr, *rest)
4545
except:
4646
# In the event of an error, restore the terminal
4747
# to a sane state.

Lib/lib-tk/Canvas.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def config(self, cnf={}, **kw):
5555
def coords(self, pts = ()):
5656
flat = ()
5757
for x, y in pts: flat = flat + (x, y)
58-
return apply(self.canvas.coords, (self.id,) + flat)
58+
return self.canvas.coords(self.id, *flat)
5959
def dchars(self, first, last=None):
6060
self.canvas.dchars(self.id, first, last)
6161
def dtag(self, ttd):
@@ -84,40 +84,40 @@ def type(self):
8484

8585
class Arc(CanvasItem):
8686
def __init__(self, canvas, *args, **kw):
87-
apply(CanvasItem.__init__, (self, canvas, 'arc') + args, kw)
87+
CanvasItem.__init__(self, canvas, 'arc', *args, **kw)
8888

8989
class Bitmap(CanvasItem):
9090
def __init__(self, canvas, *args, **kw):
91-
apply(CanvasItem.__init__, (self, canvas, 'bitmap') + args, kw)
91+
CanvasItem.__init__(self, canvas, 'bitmap', *args, **kw)
9292

9393
class ImageItem(CanvasItem):
9494
def __init__(self, canvas, *args, **kw):
95-
apply(CanvasItem.__init__, (self, canvas, 'image') + args, kw)
95+
CanvasItem.__init__(self, canvas, 'image', *args, **kw)
9696

9797
class Line(CanvasItem):
9898
def __init__(self, canvas, *args, **kw):
99-
apply(CanvasItem.__init__, (self, canvas, 'line') + args, kw)
99+
CanvasItem.__init__(self, canvas, 'line', *args, **kw)
100100

101101
class Oval(CanvasItem):
102102
def __init__(self, canvas, *args, **kw):
103-
apply(CanvasItem.__init__, (self, canvas, 'oval') + args, kw)
103+
CanvasItem.__init__(self, canvas, 'oval', *args, **kw)
104104

105105
class Polygon(CanvasItem):
106106
def __init__(self, canvas, *args, **kw):
107-
apply(CanvasItem.__init__, (self, canvas, 'polygon') + args,kw)
107+
CanvasItem.__init__(self, canvas, 'polygon', *args, **kw)
108108

109109
class Rectangle(CanvasItem):
110110
def __init__(self, canvas, *args, **kw):
111-
apply(CanvasItem.__init__, (self, canvas, 'rectangle')+args,kw)
111+
CanvasItem.__init__(self, canvas, 'rectangle', *args, **kw)
112112

113113
# XXX "Text" is taken by the Text widget...
114114
class CanvasText(CanvasItem):
115115
def __init__(self, canvas, *args, **kw):
116-
apply(CanvasItem.__init__, (self, canvas, 'text') + args, kw)
116+
CanvasItem.__init__(self, canvas, 'text', *args, **kw)
117117

118118
class Window(CanvasItem):
119119
def __init__(self, canvas, *args, **kw):
120-
apply(CanvasItem.__init__, (self, canvas, 'window') + args, kw)
120+
CanvasItem.__init__(self, canvas, 'window', *args, **kw)
121121

122122
class Group:
123123
def __init__(self, canvas, tag=None):

Lib/lib-tk/Dialog.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ def __init__(self, master=None, cnf={}, **kw):
1515
self.widgetName = '__dialog__'
1616
Widget._setup(self, master, cnf)
1717
self.num = self.tk.getint(
18-
apply(self.tk.call,
19-
('tk_dialog', self._w,
20-
cnf['title'], cnf['text'],
21-
cnf['bitmap'], cnf['default'])
22-
+ cnf['strings']))
18+
self.tk.call(
19+
'tk_dialog', self._w,
20+
cnf['title'], cnf['text'],
21+
cnf['bitmap'], cnf['default'],
22+
*cnf['strings']))
2323
try: Widget.destroy(self)
2424
except TclError: pass
2525
def destroy(self): pass

Lib/lib-tk/ScrolledText.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ def __init__(self, master=None, cnf=None, **kw):
2424
if type(k) == ClassType or k == 'name':
2525
fcnf[k] = cnf[k]
2626
del cnf[k]
27-
self.frame = apply(Frame, (master,), fcnf)
27+
self.frame = Frame(master, **fcnf)
2828
self.vbar = Scrollbar(self.frame, name='vbar')
2929
self.vbar.pack(side=RIGHT, fill=Y)
3030
cnf['name'] = 'text'
31-
apply(Text.__init__, (self, self.frame), cnf)
31+
Text.__init__(self, self.frame, **cnf)
3232
self.pack(side=LEFT, fill=BOTH, expand=1)
3333
self['yscrollcommand'] = self.vbar.set
3434
self.vbar['command'] = self.yview

Lib/lib-tk/Tix.py

Lines changed: 39 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ class Form:
222222
See Tix documentation for complete details"""
223223

224224
def config(self, cnf={}, **kw):
225-
apply(self.tk.call, ('tixForm', self._w) + self._options(cnf, kw))
225+
self.tk.call('tixForm', self._w, *self._options(cnf, kw))
226226

227227
form = config
228228

@@ -292,7 +292,7 @@ def __init__ (self, master=None, widgetName=None,
292292
static_options.append('options')
293293
else:
294294
static_options = ['options']
295-
295+
296296
for k,v in cnf.items()[:]:
297297
if k in static_options:
298298
extra = extra + ('-' + k, v)
@@ -304,7 +304,7 @@ def __init__ (self, master=None, widgetName=None,
304304
# If widgetName is None, this is a dummy creation call where the
305305
# corresponding Tk widget has already been created by Tix
306306
if widgetName:
307-
apply(self.tk.call, (widgetName, self._w) + extra)
307+
self.tk.call(widgetName, self._w, *extra)
308308

309309
# Non-static options - to be done via a 'config' command
310310
if cnf:
@@ -474,8 +474,8 @@ def __init__(self, itemtype, cnf={}, **kw ):
474474
elif not master and kw.has_key('refwindow'): master= kw['refwindow']
475475
elif not master: raise RuntimeError, "Too early to create display style: no root window"
476476
self.tk = master.tk
477-
self.stylename = apply(self.tk.call, ('tixDisplayStyle', itemtype) +
478-
self._options(cnf,kw) )
477+
self.stylename = self.tk.call('tixDisplayStyle', itemtype,
478+
*self._options(cnf,kw) )
479479

480480
def __str__(self):
481481
return self.stylename
@@ -499,8 +499,8 @@ def __setitem__(self,key,value):
499499
def config(self, cnf={}, **kw):
500500
return _lst2dict(
501501
self.tk.split(
502-
apply(self.tk.call,
503-
(self.stylename, 'configure') + self._options(cnf,kw))))
502+
self.tk.call(
503+
self.stylename, 'configure', *self._options(cnf,kw))))
504504

505505
def __getitem__(self,key):
506506
return self.tk.call(self.stylename, 'cget', '-%s'%key)
@@ -532,8 +532,7 @@ def __init__(self, master=None, cnf={}, **kw):
532532
def bind_widget(self, widget, cnf={}, **kw):
533533
"""Bind balloon widget to another.
534534
One balloon widget may be bound to several widgets at the same time"""
535-
apply(self.tk.call,
536-
(self._w, 'bind', widget._w) + self._options(cnf, kw))
535+
self.tk.call(self._w, 'bind', widget._w, *self._options(cnf, kw))
537536

538537
def unbind_widget(self, widget):
539538
self.tk.call(self._w, 'unbind', widget._w)
@@ -549,8 +548,7 @@ def __init__(self, master=None, cnf={}, **kw):
549548
def add(self, name, cnf={}, **kw):
550549
"""Add a button with given name to box."""
551550

552-
btn = apply(self.tk.call,
553-
(self._w, 'add', name) + self._options(cnf, kw))
551+
btn = self.tk.call(self._w, 'add', name, *self._options(cnf, kw))
554552
self.subwidget_list[name] = _dummyButton(self, name)
555553
return btn
556554

@@ -589,7 +587,7 @@ def __init__ (self, master=None, cnf={}, **kw):
589587
pass
590588

591589
# align
592-
590+
593591
def add_history(self, str):
594592
self.tk.call(self._w, 'addhistory', str)
595593

@@ -862,14 +860,13 @@ def __init__ (self,master=None,cnf={}, **kw):
862860
['columns', 'options'], cnf, kw)
863861

864862
def add(self, entry, cnf={}, **kw):
865-
return apply(self.tk.call,
866-
(self._w, 'add', entry) + self._options(cnf, kw))
863+
return self.tk.call(self._w, 'add', entry, *self._options(cnf, kw))
867864

868865
def add_child(self, parent=None, cnf={}, **kw):
869866
if not parent:
870867
parent = ''
871-
return apply(self.tk.call,
872-
(self._w, 'addchild', parent) + self._options(cnf, kw))
868+
return self.tk.call(
< 10000 code>869+
self._w, 'addchild', parent, *self._options(cnf, kw))
873870

874871
def anchor_set(self, entry):
875872
self.tk.call(self._w, 'anchor', 'set', entry)
@@ -909,16 +906,15 @@ def dropsite_clear(self):
909906
self.tk.call(self._w, 'dropsite', 'clear')
910907

911908
def header_create(self, col, cnf={}, **kw):
912-
apply(self.tk.call,
913-
(self._w, 'header', 'create', col) + self._options(cnf, kw))
909+
self.tk.call(self._w, 'header', 'create', col, *self._options(cnf, kw))
914910

915911
def header_configure(self, col, cnf={}, **kw):
916912
if cnf is None:
917913
return _lst2dict(
918914
self.tk.split(
919915
self.tk.call(self._w, 'header', 'configure', col)))
920-
apply(self.tk.call, (self._w, 'header', 'configure', col)
921-
+ self._options(cnf, kw))
916+
self.tk.call(self._w, 'header', 'configure', col,
917+
*self._options(cnf, kw))
922918

923919
def header_cget(self, col, opt):
924920
return self.tk.call(self._w, 'header', 'cget', col, opt)
@@ -936,16 +932,16 @@ def hide_entry(self, entry):
936932
self.tk.call(self._w, 'hide', 'entry', entry)
937933

938934
def indicator_create(self, entry, cnf={}, **kw):
939-
apply(self.tk.call,
940-
(self._w, 'indicator', 'create', entry) + self._options(cnf, kw))
935+
self.tk.call(
936+
self._w, 'indicator', 'create', entry, *self._options(cnf, kw))
941937

942938
def indicator_configure(self, entry, cnf={}, **kw):
943939
if cnf is None:
944940
return _lst2dict(
945941
self.tk.split(
946942
self.tk.call(self._w, 'indicator', 'configure', entry)))
947-
apply(self.tk.call,
948-
(self._w, 'indicator', 'configure', entry) + self._options(cnf, kw))
943+
self.tk.call(
944+
self._w, 'indicator', 'configure', entry, *self._options(cnf, kw))
949945

950946
def indicator_cget(self, entry, opt):
951947
return self.tk.call(self._w, 'indicator', 'cget', entry, opt)
@@ -996,12 +992,12 @@ def item_configure(self, entry, col, cnf={}, **kw):
996992
return _lst2dict(
997993
self.tk.split(
998994
self.tk.call(self._w, 'item', 'configure', entry, col)))
999-
apply(self.tk.call, (self._w, 'item', 'configure', entry, col) +
1000-
self._options(cnf, kw))
995+
self.tk.call(self._w, 'item', 'configure', entry, col,
996+
*self._options(cnf, kw))
1001997

1002998
def item_create(self, entry, col, cnf={}, **kw):
1003-
apply(self.tk.call,
1004-
(self._w, 'item', 'create', entry, col) + self._options(cnf, kw))
999+
self.tk.call(
1000+
self._w, 'item', 'create', entry, col, *self._options(cnf, kw))
10051001

10061002
def item_exists(self, entry, col):
10071003
return self.tk.call(self._w, 'item', 'exists', entry, col)
@@ -1016,8 +1012,7 @@ def see(self, entry):
10161012
self.tk.call(self._w, 'see', entry)
10171013

10181014
def selection_clear(self, cnf={}, **kw):
1019-
apply(self.tk.call,
1020-
(self._w, 'selection', 'clear') + self._options(cnf, kw))
1015+
self.tk.call(self._w, 'selection', 'clear', *self._options(cnf, kw))
10211016

10221017
def selection_includes(self, entry):
10231018
return self.tk.call(self._w, 'selection', 'includes', entry)
@@ -1029,10 +1024,10 @@ def show_entry(self, entry):
10291024
return self.tk.call(self._w, 'show', 'entry', entry)
10301025

10311026
def xview(self, *args):
1032-
apply(self.tk.call, (self._w, 'xview') + args)
1027+
self.tk.call(self._w, 'xview', *args)
10331028

10341029
def yview(self, *args):
1035-
apply(self.tk.call, (self._w, 'yview') + args)
1030+
self.tk.call(self._w, 'yview', *args)
10361031

10371032
class InputOnly(TixWidget):
10381033
"""InputOnly - Invisible widget. Unix only.
@@ -1093,8 +1088,7 @@ def __init__(self, master, cnf={}, **kw):
10931088
self.subwidget_list['shlist'] = _dummyScrolledHList(self, 'shlist')
10941089

10951090
def add(self, name, cnf={}, **kw):
1096-
apply(self.tk.call,
1097-
(self._w, 'add', name) + self._options(cnf, kw))
1091+
self.tk.call(self._w, 'add', name, *self._options(cnf, kw))
10981092
self.subwidget_list[name] = TixSubWidget(self, name)
10991093
return self.subwidget_list[name]
11001094

@@ -1135,8 +1129,7 @@ def __init__ (self,master=None,cnf={}, **kw):
11351129
destroy_physically=0)
11361130

11371131
def add(self, name, cnf={}, **kw):
1138-
apply(self.tk.call,
1139-
(self._w, 'add', name) + self._options(cnf, kw))
1132+
self.tk.call(self._w, 'add', name, *self._options(cnf, kw))
11401133
self.subwidget_list[name] = TixSubWidget(self, name)
11411134
return self.subwidget_list[name]
11421135

@@ -1180,12 +1173,10 @@ def __init__(self, master, cnf={}, **kw):
11801173
self.subwidget_list['menu'] = _dummyMenu(self, 'menu')
11811174

11821175
def add_command(self, name, cnf={}, **kw):
1183-
apply(self.tk.call,
1184-
(self._w, 'add', 'command', name) + self._options(cnf, kw))
1176+
self.tk.call(self._w, 'add', 'command', name, *self._options(cnf, kw))
11851177

11861178
def add_separator(self, name, cnf={}, **kw):
1187-
apply(self.tk.call,
1188-
(self._w, 'add', 'separator', name) + self._options(cnf, kw))
1179+
self.tk.call(self._w, 'add', 'separator', name, *self._options(cnf, kw))
11891180

11901181
def delete(self, name):
11911182
self.tk.call(self._w, 'delete', name)
@@ -1212,8 +1203,7 @@ def __init__(self, master, cnf={}, **kw):
12121203

12131204
# add delete forget panecget paneconfigure panes setsize
12141205
def add(self, name, cnf={}, **kw):
1215-
apply(self.tk.call,
1216-
(self._w, 'add', name) + self._options(cnf, kw))
1206+
self.tk.call(self._w, 'add', name, *self._options(cnf, kw))
12171207
self.subwidget_list[name] = TixSubWidget(self, name,
12181208
check_intermediate=0)
12191209
return self.subwidget_list[name]
@@ -1234,8 +1224,7 @@ def paneconfigure(self, entry, cnf={}, **kw):
12341224
return _lst2dict(
12351225
self.tk.split(
12361226
self.tk.call(self._w, 'paneconfigure', entry)))
1237-
apply(self.tk.call,
1238-
(self._w, 'paneconfigure', entry) + self._options(cnf, kw))
1227+
self.tk.call(self._w, 'paneconfigure', entry, *self._options(cnf, kw))
12391228

12401229
def panes(self):
12411230
names = self.tk.call(self._w, 'panes')
@@ -1361,8 +1350,7 @@ def __init__(self, master, cnf={}, **kw):
13611350
self.subwidget_list['label'] = _dummyLabel(self, 'label')
13621351

13631352
def add(self, name, cnf={}, **kw):
1364-
apply(self.tk.call,
1365-
(self._w, 'add', name) + self._options(cnf, kw))
1353+
self.tk.call(self._w, 'add', name, *self._options(cnf, kw))
13661354
self.subwidget_list[name] = _dummyButton(self, name)
13671355
return self.subwidget_list[name]
13681356

@@ -1458,8 +1446,7 @@ def dropsite_clear(self):
14581446
self.tk.call(self._w, 'dropsite', 'clear')
14591447

14601448
def insert(self, index, cnf={}, **kw):
1461-
apply(self.tk.call,
1462-
(self._w, 'insert', index) + self._options(cnf, kw))
1449+
self.tk.call(self._w, 'insert', index, *self._options(cnf, kw))
14631450

14641451
def info_active(self):
14651452
return self.tk.call(self._w, 'info', 'active')
@@ -1493,8 +1480,7 @@ def see(self, index):
14931480
self.tk.call(self._w, 'see', index)
14941481

14951482
def selection_clear(self, cnf={}, **kw):
1496-
apply(self.tk.call,
1497-
(self._w, 'selection', 'clear') + self._options(cnf, kw))
1483+
self.tk.call(self._w, 'selection', 'clear', *self._options(cnf, kw))
14981484

14991485
def selection_includes(self, index):
15001486
return self.tk.call(self._w, 'selection', 'includes', index)
@@ -1503,10 +1489,10 @@ def selection_set(self, first, last=None):
15031489
self.tk.call(self._w, 'selection', 'set', first, last)
15041490

15051491
def xview(self, *args):
1506-
apply(self.tk.call, (self._w, 'xview') + args)
1492+
self.tk.call(self._w, 'xview', *args)
15071493

15081494
def yview(self, *args):
1509-
apply(self.tk.call, (self._w, 'yview') + args)
1495+
self.tk.call(self._w, 'yview', *args)
15101496

15111497
class Tree(TixWidget):
15121498
"""Tree - The tixTree widget can be used to display hierachical
@@ -1807,7 +1793,7 @@ class Grid(TixWidget):
18071793
# def unset x y
18081794
# def xview
18091795
# def yview
1810-
1796+
18111797
class ScrolledGrid(TixWidget):
18121798
'''Scrolled Grid widgets'''
18131799

0 commit comments

Comments
 (0)
0