all Python 3configparserexception
configparser.InterpolationDepthError
exceptions
Raised when a substitution chain does not finish within MAX_INTERPOLATION_DEPTH (10) steps, which almost always means a reference cycle.
Syntax
except configparser.InterpolationDepthError as e: ...
A cycle such as a = %(b)s and b = %(a)s is invisible on read: the file loads and get() fails. An honest chain longer than ten references triggers it too, but that is rare — look for a cycle first, including one that goes through [DEFAULT].
Examples
import configparser
cfg = configparser.ConfigParser()
cfg.read_string("[a]\nx = %(y)s\ny = %(x)s\n")
try:
cfg.get("a", "x")
except configparser.InterpolationDepthError:
print("цикл, предел", configparser.MAX_INTERPOLATION_DEPTH) # → цикл, предел 10
See also
Common errors
Open in the full glossarydocs.python.orgReport an inaccuracy