You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
IndexError when indent contains {number} and input has nested dict/list #33
When calling dict2xml() with an indent string that contains a substring like {1111} (i.e., a placeholder with a numeric index) and the input data contains nested structures (dict or list), the library raises an IndexError:
IndexError: Replacement index 1111 out of range for positional args tuple
This happens because the library internally uses str.format() to build the indentation string, and does not escape curly braces before substitution. As a result, the {1111} inside the indent parameter is interpreted as an index placeholder, causing the error.
The indent parameter is documented as accepting a string (not just integer), so any string should be handled safely.
Activity
delfick commentedon Jul 20, 2026
why would anyone do that though? that makes no sense