kobo.conf.PyConfigParser._get_token skips COMMENT, NL, NEWLINE, INDENT, and DEDENT tokens via recursive self-calls rather than a loop. Each skipped token consumes one Python stack frame, so a config file with many consecutive comment or blank lines will recurse proportionally deep, eventually exhausting the default recursion limit.
Steps to reproduce:
import tempfile
from kobo.conf import PyConfigParser
with tempfile.NamedTemporaryFile(mode="w", suffix=".conf", delete=False) as f:
for i in range(1000):
f.write(f"# comment {i}\n")
f.write("x = 1\n")
path = f.name
c = PyConfigParser()
c.load_from_file(path)
print("ok:", c["x"])
Expected behavior: Parses successfully.
Actual behavior: RecursionError: maximum recursion depth exceeded
kobo.conf.PyConfigParser._get_token skips COMMENT, NL, NEWLINE, INDENT, and DEDENT tokens via recursive self-calls rather than a loop. Each skipped token consumes one Python stack frame, so a config file with many consecutive comment or blank lines will recurse proportionally deep, eventually exhausting the default recursion limit.
Steps to reproduce:
Expected behavior: Parses successfully.
Actual behavior:
RecursionError: maximum recursion depth exceeded