MCPcopy Index your code
hub / github.com/python/cpython / ParsingError

Class ParsingError

Lib/configparser.py:305–333  ·  view source on GitHub ↗

Raised when a configuration file does not follow legal syntax.

Source from the content-addressed store, hash-verified

303
304
305class ParsingError(Error):
306 """Raised when a configuration file does not follow legal syntax."""
307
308 def __init__(self, source, *args):
309 super().__init__(f'Source contains parsing errors: {source!r}')
310 self.source = source
311 self.errors = []
312 self.args = (source, )
313 if args:
314 self.append(*args)
315
316 def append(self, lineno, line):
317 self.errors.append((lineno, line))
318 self.message += '\n\t[line %2d]: %s' % (lineno, repr(line))
319
320 def combine(self, others):
321 for other in others:
322 for error in other.errors:
323 self.append(*error)
324 return self
325
326 @staticmethod
327 def _raise_all(exceptions: Iterable['ParsingError']):
328 """
329 Combine any number of ParsingErrors into one and raise it.
330 """
331 exceptions = iter(exceptions)
332 with contextlib.suppress(StopIteration):
333 raise next(exceptions).combine(exceptions)
334
335
336

Callers 1

_handle_optionMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…