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
configparser.DuplicateOptionError leaves ConfigParser instance in bad state #116957
If you catch configparser.Error when reading a config file (the intention is to skip invalid config files) and then attempt to use the ConfigParser instance, you can get really weird errors. In the following example, read raises DuplicateOptionError from the 2nd section, but attempting to get a value from the first section fails in the interpolation code, because somehow the value has been stored as a list instead of a string!
This behaviour is because ConfigParser._read doesn't call _join_multiline_values when it raises DuplicateSectionError or DuplicateOptionError (but it does for ParsingError):
Activity
drothlis commentedon Mar 18, 2024
This behaviour is because
ConfigParser._readdoesn't call_join_multiline_valueswhen it raises DuplicateSectionError or DuplicateOptionError (but it does for ParsingError):cpython/Lib/configparser.py
Lines 1059 to 1062 in 43c9d61
pythongh-116957: configparser: Do post-process values after Duplicate…
pythongh-116957: Add NEWS blurb
gh-116957: configparser: Do post-process values after DuplicateOption…
[3.11] pythongh-116957: configparser: Do post-process values after Du…
[3.12] pythongh-116957: configparser: Do post-process values after Du…
[3.12] gh-116957: configparser: Do post-process values after Duplicat…
[3.11] gh-116957: configparser: Do post-process values after Duplicat…
pythongh-116957: configparser: Do post-process values after Duplicate…
pythongh-116957: configparser: Do post-process values after Duplicate…
pythongh-116957: configparser: Do post-process values after Duplicate…