diff options
Diffstat (limited to 'Lib/ConfigParser.py')
| -rw-r--r-- | Lib/ConfigParser.py | 34 | 
1 files changed, 33 insertions, 1 deletions
diff --git a/Lib/ConfigParser.py b/Lib/ConfigParser.py index 963a418..0493739 100644 --- a/Lib/ConfigParser.py +++ b/Lib/ConfigParser.py @@ -134,6 +134,9 @@ class Error(Exception):      def __repr__(self):          return self.message +    def __reduce__(self): +        return self.__class__, (self.message,) +      __str__ = __repr__  class NoSectionError(Error): @@ -143,6 +146,9 @@ class NoSectionError(Error):          Error.__init__(self, 'No section: %r' % (section,))          self.section = section +    def __reduce__(self): +        return self.__class__, (self.section,) +  class DuplicateSectionError(Error):      """Raised when a section is multiply-created.""" @@ -150,6 +156,9 @@ class DuplicateSectionError(Error):          Error.__init__(self, "Section %r already exists" % section)          self.section = section +    def __reduce__(self): +        return self.__class__, (self.section,) +  class NoOptionError(Error):      """A requested option was not found.""" @@ -159,6 +168,9 @@ class NoOptionError(Error):          self.option = option          self.section = section +    def __reduce__(self): +        return self.__class__, (self.option, self.section) +  class InterpolationError(Error):      """Base class for interpolation-related exceptions.""" @@ -167,6 +179,9 @@ class InterpolationError(Error):          self.option = option          self.section = section +    def __reduce__(self): +        return self.__class__, (self.option, self.section, self.message) +  class InterpolationMissingOptionError(InterpolationError):      """A string substitution required a setting which was not available.""" @@ -179,6 +194,11 @@ class InterpolationMissingOptionError(InterpolationError):                 % (section, option, reference, rawval))          InterpolationError.__init__(self, option, section, msg)          self.reference = reference +        self._rawval = rawval + +    def __reduce__(self): +        return self.__class__, (self.option, self.section, self._rawval, +            self.reference)  class InterpolationSyntaxError(InterpolationError):      """Raised when the source text into which substitutions are made @@ -194,19 +214,28 @@ class InterpolationDepthError(InterpolationError):                 "\trawval : %s\n"                 % (section, option, rawval))          InterpolationError.__init__(self, option, section, msg) +        self._rawval = rawval + +    def __reduce__(self): +        return self.__class__, (self.option, self.section, self._rawval)  class ParsingError(Error):      """Raised when a configuration file does not follow legal syntax.""" -    def __init__(self, filename): +    def __init__(self, filename, _errors=[]):          Error.__init__(self, 'File contains parsing errors: %s' % filename)          self.filename = filename          self.errors = [] +        for lineno, line in _errors: +            self.append(lineno, line)      def append(self, lineno, line):          self.errors.append((lineno, line))          self.message += '\n\t[line %2d]: %s' % (lineno, line) +    def __reduce__(self): +        return self.__class__, (self.filename, self.errors) +  class MissingSectionHeaderError(ParsingError):      """Raised when a key-value pair is found before any section header.""" @@ -219,6 +248,9 @@ class MissingSectionHeaderError(ParsingError):          self.lineno = lineno          self.line = line +    def __reduce__(self): +        return self.__class__, (self.filename, self.lineno, self.line) +  class RawConfigParser:      def __init__(self, defaults=None, dict_type=_default_dict,  | 
