On this page
configparser.MissingSectionHeaderError
Prev: configparser.InvalidWriteError | Up: configparser | Next: configparser.MultilineContinuationError
Rel: configparser.BasicInterpolation, configparser.ConfigParser, configparser.ConverterMapping, configparser.DuplicateOptionError
Ref: docs.python.org — configparser.MissingSectionHeaderError
Tags: #public #python3 #stdlib #configparser
Import
import configparser
from configparser import MissingSectionHeaderError
Signature & Overview
configparser.MissingSectionHeaderError(filename, lineno, line)
Raised when a key-value pair is found before any section header.
Methods & Attributes
MissingSectionHeaderError.add_note(self, note, /)— Add a note to the exceptionMissingSectionHeaderError.append(self, lineno, line)—MissingSectionHeaderError.appendmethod/property.MissingSectionHeaderError.combine(self, others)—MissingSectionHeaderError.combinemethod/property.MissingSectionHeaderError.with_traceback(self, tb, /)— Set self.traceback to tb and return self.
Usage
import configparser
cp = configparser.ConfigParser()
try:
cp.read_string("key = value\n")
except configparser.MissingSectionHeaderError:
assert True
Gotchas
- Standard INI requires a
[section]header first (or passallow_unnamed_section=Truein Python 3.13+).
REPL Inspect
from configparser import MissingSectionHeaderError
help(MissingSectionHeaderError)
Linked from
Related notes
- tuts/python3/stdlib_module/configparser/InvalidWriteError Linked here; links to this page; shared tags: #configparser, #stdlib
- tuts/python3/stdlib_module/configparser/MultilineContinuationError Linked here; links to this page; shared tags: #configparser, #stdlib
- tuts/python3/stdlib_module/configparser/BasicInterpolation Linked here; shared tags: #configparser, #stdlib
- tuts/python3/stdlib_module/configparser/ConfigParser Linked here; shared tags: #configparser, #stdlib
- tuts/python3/stdlib_module/configparser/ConverterMapping Linked here; shared tags: #configparser, #stdlib
- tuts/python3/stdlib_module/configparser/DuplicateOptionError Linked here; shared tags: #configparser, #stdlib
- tuts/python3/stdlib_module/configparser links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/configparser/DuplicateSectionError shared tags: #configparser, #stdlib
- tuts/python3/stdlib_module/configparser/ExtendedInterpolation shared tags: #configparser, #stdlib
- tuts/python3/stdlib_module/configparser/Interpolation shared tags: #configparser, #stdlib