bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] gnulib-tool.py: Append, don't replace existing VCS ignore fi


From: Darshit Shah
Subject: Re: [PATCH] gnulib-tool.py: Append, don't replace existing VCS ignore files
Date: Mon, 11 Sep 2017 14:03:33 +0200
User-agent: NeoMutt/20170714-155-820ab5 (1.8.3)

* Eric Blake <address@hidden> [170911 14:00]:
> On 09/11/2017 06:49 AM, Darshit Shah wrote:
> > * pygnulib/GLImport.py(_update_ignorelist_): Append the ignore data to
> > any existing VCS ignore files instead of replacing them
> > ---
> >  pygnulib/GLImport.py | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py
> > index 4352a7ec5..b0e3ec655 100644
> > --- a/pygnulib/GLImport.py
> > +++ b/pygnulib/GLImport.py
> > @@ -726,9 +726,9 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
> >                      if not self.config['dryrun']:
> >                          print('Updating %s (backup in %s)' %
> >                                (srcpath, backupname))
> > -                        shutil.move(srcpath, backupname)
> > +                        shutil.copy2(srcpath, backupname)
> >                          result = string()
> > -                        with codecs.open(srcpath, 'wb', 'UTF-8') as file:
> > +                        with codecs.open(srcpath, 'a', 'UTF-8') as file:
> 
> Shouldn't you use 'ab' to force the append in binary rather than text
> mode, since the old code was using 'wb'?
> 

According to the documentation for the 'codec' module[1]:
> Note
> 
> Underlying encoded files are always opened in binary mode. No automatic
> conversion of '\n' is done on reading and writing. The mode argument may
> be any binary mode acceptable to the built-in open() function; the 'b'
> is automatically added. 

So, the 'b' is not strictly required. However, since you mention it, it
may be sensible to add it nonetheless just to be more explicit about the
expected behavior.

[1]: https://docs.python.org/3/library/codecs.html


-- 
Thanking You,
Darshit Shah
PGP Fingerprint: 7845 120B 07CB D8D6 ECE5 FF2B 2A17 43ED A91A 35B6

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]