[PATCH] pwclient: handle missing ~/.pwclientrc better

Mike Frysinger vapier at gentoo.org
Thu May 7 16:36:03 AEST 2015


On 06 May 2015 17:53, Keller, Jacob E wrote:
> On Tue, 2015-05-05 at 23:37 -0400, Mike Frysinger wrote:
> > --- a/apps/patchwork/bin/pwclient
> > +++ b/apps/patchwork/bin/pwclient
> > @@ -552,7 +552,7 @@ def main():
> >      config = ConfigParser.ConfigParser()
> >      config.read([CONFIG_FILE])
> >  
> > -    if not config.has_section('options'):
> > +    if not config.has_section('options') and os.path.exists(CONFIG_FILE):
> >          sys.stderr.write('~/.pwclientrc is in the old format. Migrating it...')
> 
> Doesn't it make more logical sense to check this in reverse order:
> 
> if os.path.exists(CONFIG_FILE) and not config.has_section('options'):
> 
> That makes more sense to read even if both end up working correctly?

the system already read & loaded the config file.  that is the normal code flow.  
so checking if it has the options section will pass quickly and thus skip the 
branch entirely.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.ozlabs.org/pipermail/patchwork/attachments/20150507/6cea48c9/attachment.sig>


More information about the Patchwork mailing list