Python Glossary Русский

Python 3.13+configparserexception

configparser.MultilineContinuationError

exceptions

Raised with allow_no_value=True when a key without a value is followed by an indented continuation line. A subclass of ParsingError.

Syntax

except configparser.MultilineContinuationError as e: e.lineno, e.line

Indented lines in INI continue the previous value, and a key without a value has nothing to continue. Before 3.13 the same file crashed the parser with an obscure AttributeError: 'NoneType' object has no attribute 'append', so on older versions that is what you catch. The usual cause is an accidental indent on the next line.

Examples

import configparser
cfg = configparser.ConfigParser(allow_no_value=True)
try:
    cfg.read_string("[flags]\nverbose\n  extra\n")
except configparser.MultilineContinuationError as e:
    print(e.lineno, repr(e.line))  # → 3 '  extra\n'

See also

Common errors

Open in the full glossarydocs.python.orgReport an inaccuracy