def test_interpolationmissingoptionerror(self): import pickle e1 = ConfigParser.InterpolationMissingOptionError('option', 'section', 'rawval', 'reference') pickled = pickle.dumps(e1) e2 = pickle.loads(pickled) self.assertEqual(e1.message, e2.message) self.assertEqual(e1.args, e2.args) self.assertEqual(e1.section, e2.section) self.assertEqual(e1.option, e2.option) self.assertEqual(e1.reference, e2.reference) self.assertEqual(repr(e1), repr(e2))
def _interpolate(self, section, option, rawval, _vars): # do the string interpolation value = rawval depth = ConfigParser.MAX_INTERPOLATION_DEPTH while depth: # Loop through this until it's done depth -= 1 if "%(" in value: value = self._KEYCRE.sub(self._interpolation_replace, value) try: value = value % _vars except KeyError, e: raise ConfigParser.InterpolationMissingOptionError( option, section, rawval, e[0]) else: break