--- /usr/lib/python2.7/ConfigParser.py 2013-11-20 12:09:26.000000000 +0000 +++ ConfigParser.py 2013-11-30 15:00:50.281500770 +0000 @@ -52,11 +52,11 @@ The filename defaults to fp.name; it is only used in error messages (if fp has no `name' attribute, the string `' is used). - get(section, option, raw=False, vars=None) + get(section, option, raw=False, vvars=None) return a string value for the named option. All % interpolations are expanded in the return values, based on the defaults passed into the constructor and the DEFAULT section. Additional substitutions may be - provided using the `vars' argument, which must be a dictionary whose + provided using the `vvars' argument, which must be a dictionary whose contents override any pre-existing defaults. getint(section, options) @@ -70,7 +70,7 @@ insensitively defined as 0, false, no, off for False, and 1, true, yes, on for True). Returns False or True. - items(section, raw=False, vars=None) + items(section, raw=False, vvars=None) return a list of tuples with (name, value) for each option in the section. @@ -228,7 +228,7 @@ self.args = (filename, lineno, line) -class RawConfigParser: +class RawConfigParser(object): def __init__(self, defaults=None, dict_type=_default_dict, allow_no_value=False): self._dict = dict_type @@ -258,7 +258,7 @@ case-insensitive variants. """ if section.lower() == "default": - raise ValueError, 'Invalid section name: %s' % section + raise ValueError('Invalid section name: %s' % section) if section in self._sections: raise DuplicateSectionError(section) @@ -367,7 +367,7 @@ def getboolean(self, section, option): v = self.get(section, option) if v.lower() not in self._boolean_states: - raise ValueError, 'Not a boolean: %s' % v + raise ValueError('Not a boolean: %s' % v) return self._boolean_states[v.lower()] def optionxform(self, optionstr): @@ -542,9 +542,7 @@ e = ParsingError(fpname) e.append(lineno, repr(line)) # if any parsing errors occurred, raise an exception - if e: - raise e - + # join the multi-line values collected while reading all_sections = [self._defaults] all_sections.extend(self._sections.values()) @@ -561,7 +559,7 @@ For example, to emulate Python's normal lookup sequence: import __builtin__ - pylookup = _Chainmap(locals(), globals(), vars(__builtin__)) + pylookup = _Chainmap(locals(), globals(), vvars(__builtin__)) """ def __init__(self, *maps): @@ -587,11 +585,11 @@ class ConfigParser(RawConfigParser): - def get(self, section, option, raw=False, vars=None): + def get(self, section, option, raw=False, vvars=None): """Get an option value for a given section. - If `vars' is provided, it must be a dictionary. The option is looked up - in `vars' (if provided), `section', and in `defaults' in that order. + If `vvars' is provided, it must be a dictionary. The option is looked up + in `vvars' (if provided), `section', and in `defaults' in that order. All % interpolations are expanded in the return values, unless the optional argument `raw' is true. Values for interpolation keys are @@ -607,8 +605,8 @@ raise NoSectionError(section) # Update with the entry specific variables vardict = {} - if vars: - for key, value in vars.items(): + if vvars: + for key, value in vvars.items(): vardict[self.optionxform(key)] = value d = _Chainmap(vardict, sectiondict, self._defaults) option = self.optionxform(option) @@ -622,14 +620,14 @@ else: return self._interpolate(section, option, value, d) - def items(self, section, raw=False, vars=None): + def items(self, section, raw=False, vvars=None): """Return a list of tuples with (name, value) for each option in the section. All % interpolations are expanded in the return values, based on the defaults passed into the constructor, unless the optional argument `raw' is true. Additional substitutions may be provided using the - `vars' argument, which must be a dictionary whose contents overrides + `vvars' argument, which must be a dictionary whose contents overrides any pre-existing defaults. The section DEFAULT is special. @@ -641,8 +639,8 @@ if section != DEFAULTSECT: raise NoSectionError(section) # Update with the entry specific variables - if vars: - for key, value in vars.items(): + if vvars: + for key, value in vvars.items(): d[self.optionxform(key)] = value options = d.keys() if "__name__" in options: @@ -654,7 +652,7 @@ return [(option, self._interpolate(section, option, d[option], d)) for option in options] - def _interpolate(self, section, option, rawval, vars): + def _interpolate(self, section, option, rawval, vvars): # do the string interpolation value = rawval depth = MAX_INTERPOLATION_DEPTH @@ -663,7 +661,7 @@ if value and "%(" in value: value = self._KEYCRE.sub(self._interpolation_replace, value) try: - value = value % vars + value = value % vvars except KeyError, e: raise InterpolationMissingOptionError( option, section, rawval, e.args[0]) @@ -685,15 +683,15 @@ class SafeConfigParser(ConfigParser): - def _interpolate(self, section, option, rawval, vars): + def _interpolate(self, section, option, rawval, vvars): # do the string interpolation L = [] - self._interpolate_some(option, L, rawval, section, vars, 1) + self._interpolate_some(option, L, rawval, section, vvars, 1) return ''.join(L) _interpvar_re = re.compile(r"%\(([^)]+)\)s") - def _interpolate_some(self, option, accum, rest, section, map, depth): + def _interpolate_some(self, option, accum, rest, section, mmap, depth): if depth > MAX_INTERPOLATION_DEPTH: raise InterpolationDepthError(option, section, rest) while rest: @@ -717,13 +715,13 @@ var = self.optionxform(m.group(1)) rest = rest[m.end():] try: - v = map[var] + v = mmap[var] except KeyError: raise InterpolationMissingOptionError( option, section, rest, var) if "%" in v: self._interpolate_some(option, accum, v, - section, map, depth + 1) + section, mmap, depth + 1) else: accum.append(v) else: