[git-buildpackage] [PATCH] config: modify configparser import statement

Markus Lehtonen markus.lehtonen at linux.intel.com
Tue Feb 24 11:44:17 CET 2015


Hi,

On Mon, 2015-02-23 at 17:07 +0100, Guido Günther wrote:
> Hi,
> On Mon, Feb 23, 2015 at 05:11:04PM +0200, Markus Lehtonen wrote:
> > Usage of six.moves.configparser in the previous way failed at least with
> > some versions of python and python-six.
> 
> HOW does it fail? Which version of six? I'm using 1.8.0.

Like this:
---- SNIP ------------------------------------------
$ python
Python 2.7.6 (default, Nov 21 2013, 15:55:38) [GCC] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from six.moves.configparser import SafeConfigParser
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named configparser
>>> 
---- SNIP ------------------------------------------

I have python-six v1.4.1 (openSUSE 13.1). Same problem seems to happen
also on Debian-7, for example.

Thanks,
  Markus


> Cheers,
>  -- Guido
> 
> > 
> > Signed-off-by: Markus Lehtonen <markus.lehtonen at linux.intel.com>
> > ---
> >  gbp/config.py | 8 ++++----
> >  1 file changed, 4 insertions(+), 4 deletions(-)
> > 
> > diff --git a/gbp/config.py b/gbp/config.py
> > index cc46cf7..dd8905d 100644
> > --- a/gbp/config.py
> > +++ b/gbp/config.py
> > @@ -17,7 +17,7 @@
> >  """handles command line and config file option parsing for the gbp commands"""
> >  
> >  from optparse import OptionParser, OptionGroup, Option, OptionValueError
> > -from six.moves.configparser import SafeConfigParser, NoSectionError
> > +from six.moves import configparser
> >  from copy import copy
> >  import os.path
> >  
> > @@ -368,7 +368,7 @@ class GbpOptionParser(OptionParser):
> >          Parse the possible config files and set appropriate values
> >          default values
> >          """
> > -        parser = SafeConfigParser()
> > +        parser = configparser.SafeConfigParser()
> >          # Fill in the built in values
> >          self.config = dict(self.__class__.defaults)
> >          # Update with the values from the defaults section. This is needed
> > @@ -412,8 +412,8 @@ class GbpOptionParser(OptionParser):
> >              if parser.has_section(section):
> >                  self.config.update(dict(parser._sections[section].items()))
> >              else:
> > -                raise NoSectionError("Mandatory section [%s] does not exist."
> > -                                     % section)
> > +                raise configparser.NoSectionError(
> > +                        "Mandatory section [%s] does not exist." % section)
> >  
> >          # filter can be either a list or a string, always build a list:
> >          if self.config['filter']:
> > -- 
> > 1.8.4.5
> > 




More information about the git-buildpackage mailing list