[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn commit: r33757 - in trunk: build/generator subversion/bindings/swig/python/svn subversion/tests/cmdline subversion/tests/cmdline/svntest tools/examples

From: Arfrever Frehtes Taifersar Arahesis <arfrever.fta_at_gmail.com>
Date: Sun, 19 Oct 2008 21:53:54 +0200

2008-10-19 18:50:36 Greg Stein napisaƂ(a):
> Arfrever,
>
> When using apply(), positional arguments needed to be prepended to the
> list of arguments. So the calls looked like:
>
> apply(func, (arg1, arg2) + arg_list)
>
> In the new calling style, you can simply do:
>
> func(arg1, arg2, *arg_list)
>
> So in your translation below, you should no longer be adding argument
> sequences together.
>
> Second, apply required a second argument if you were going to use
> keyword arguments. So the calls looked like:
>
> apply(func, (), kw)
>
> This should simply be translated as:
>
> func(**kw)
>
> Details below:
>
> On Sun, Oct 19, 2008 at 9:31 AM, <arfrever_at_tigris.org> wrote:
> >...
> > +++ trunk/build/generator/gen_base.py Sun Oct 19 09:31:08 2008 (r33757)
> >...
> > @@ -697,9 +697,8 @@ class TargetJavaClasses(TargetJava):
> > sourcedirs = dirs[:-1] # Last element is the .class file name.
> > while sourcedirs:
> > if sourcedirs.pop() in self.packages:
> > - sourcepath = apply(build_path_join, sourcedirs)
> > - objname = apply(build_path_join,
> > - [self.classes] + dirs[len(sourcedirs):])
> > + sourcepath = build_path_join(*sourcedirs)
> > + objname = build_path_join(*[self.classes] + dirs[len(sourcedirs):])
>
> build_path_join(self.classes, *dirs[...
>
> >...
> > +++ trunk/subversion/bindings/swig/python/svn/core.py Sun Oct 19 09:31:08 2008 (r33757)
> > @@ -280,4 +280,4 @@ def run_app(func, *args, **kw):
> > APR is initialized, and an application pool is created. Cleanup is
> > performed as the function exits (normally or via an exception).
> > '''
> > - return apply(func, (application_pool,) + args, kw)
> > + return func(*(application_pool,) + args, **kw)
>
> application_pool should be pulled out
>
> >...
> > +++ trunk/subversion/tests/cmdline/getopt_tests.py Sun Oct 19 09:31:08 2008 (r33757)
> > @@ -115,12 +115,10 @@ def run_one_test(sbox, basename, *vararg
> >
> > # special case the 'svn' test so that no extra arguments are added
> > if basename != 'svn':
> > - exit_code, actual_stdout, actual_stderr = apply(svntest.main.run_svn,
> > - (1,) + varargs)
> > + exit_code, actual_stdout, actual_stderr = svntest.main.run_svn(*(1,) + varargs)
>
> Pull out the 1
>
> > else:
> > - exit_code, actual_stdout, actual_stderr = apply(svntest.main.run_command,
> > - (svntest.main.svn_binary,
> > - 1, 0) + varargs)
> > + exit_code, actual_stdout, actual_stderr = svntest.main.run_command(*(svntest.main.svn_binary,
> > + 1, 0) + varargs)
>
> similar
>
> >...
> > +++ trunk/subversion/tests/cmdline/svntest/main.py Sun Oct 19 09:31:08 2008 (r33757)
> > @@ -1122,7 +1122,7 @@ class TestRunner:
> >
> > saved_dir = os.getcwd()
> > try:
> > - rc = apply(self.pred.run, (), kw)
> > + rc = self.pred.run(*(), **kw)
>
> Drop the *(),
>
> >...
> > +++ trunk/subversion/tests/cmdline/svntest/wc.py Sun Oct 19 09:31:08 2008 (r33757)
> > @@ -87,16 +87,16 @@ class State:
> > except KeyError, e:
> > e.args = ["Path '%s' not present in WC state descriptor" % path]
> > raise
> > - apply(path_ref.tweak, (), kw)
> > + path_ref.tweak(*(), **kw)
>
> same
>
> > else:
> > for item in self.desc.values():
> > - apply(item.tweak, (), kw)
> > + item.tweak(*(), **kw)
>
> same
>
> >
> > def tweak_some(self, filter, **kw):
> > "Tweak the items for which the filter returns true."
> > for path, item in self.desc.items():
> > if filter(path, item):
> > - apply(item.tweak, (), kw)
> > + item.tweak(*(), **kw)
>
> same
>
> >...
> > +++ trunk/tools/examples/revplist.py Sun Oct 19 09:31:08 2008 (r33757)
> > @@ -65,7 +65,7 @@ def main():
> > elif name == '-h':
> > home = value
> >
> > - apply(plist, (rev, home) + tuple(args))
> > + plist(*(rev, home) + tuple(args))
>
> rev, home should be their own args. no need to call tuple() since
> *args will take any sequence type.

The code was simplified in r33759.

-- 
Arfrever Frehtes Taifersar Arahesis

Received on 2008-10-19 21:58:18 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.