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

Re: [PATCH] swig-py: restrict *-import to svn_* names

From: Branko Čibej <brane_at_apache.org>
Date: Sun, 18 Mar 2012 16:54:06 +0100

On 18.03.2012 15:33, Daniel Shahaf wrote:
> Branko Čibej wrote on Sun, Mar 18, 2012 at 14:18:50 +0100:
>> On 18.03.2012 12:52, Daniel Shahaf wrote:
>>> Роман Донченко wrote on Sun, Mar 18, 2012 at 15:36:24 +0400:
>>>> Daniel Shahaf <danielsh_at_elego.de> писал в своём письме Sun, 18 Mar
>>>> 2012 04:07:45 +0400:
>>>>
>>>>> [[[
>>>>> Index: subversion/bindings/swig/python/svn/fs.py
>>>>> ===================================================================
>>>>> --- subversion/bindings/swig/python/svn/fs.py (revision 1301511)
>>>>> +++ subversion/bindings/swig/python/svn/fs.py (working copy)
>>>>> @@ -27,6 +27,7 @@ from libsvn.fs import *
>>>>> from svn.core import _unprefix_names, Pool
>>>>> _unprefix_names(locals(), 'svn_fs_')
>>>>> _unprefix_names(locals(), 'SVN_FS_')
>>>>> +__all__ = filter(lambda x: x.lower().startswith('svn_'),
>>>>> locals().keys())
>>>>> del _unprefix_names
>>>>> ]]]
>>>>>
>>>>> Before:
>>>>> % python -c 'from svn.fs import *;
>>>>> print [x for x in locals().keys() if "begin_txn2" in x]'
>>>>> ['svn_fs_begin_txn2', 'begin_txn2']
>>>>>
>>>>> After:
>>>>> % python -c 'from svn.fs import *;
>>>>> print [x for x in locals().keys() if "begin_txn2" in x]'
>>>>> ['svn_fs_begin_txn2']
>>>>>
>>>> This would nullify the purpose of _unprefix_names, would it not?
>>>>
>>> No. It enables this code:
>>>
>>> from svn.fs import *
>>> svn_fs_begin_txn2()
>> The only trouble with this "new way" as opposed to the "old way" is that
>> it's not the "Python way" :)
>>
> The patch doesn't break things for those who use the svn.fs.begin_txn2()
> way. Those who don't use star-imports will not be affected by it.

Yes, but why do this at all?

-- Brane
Received on 2012-03-18 16:54:16 CET

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.