[issue33504] configparser should use dict instead of OrderedDict in 3.7+

Łukasz Langa report at bugs.python.org
Tue May 15 00:45:31 EDT 2018


Łukasz Langa <lukasz at langa.pl> added the comment:

I am +1 to changing it to dict for Python 3.8.

This use case is different from `namedtuple._asdict`. The type of the dictionary is for the purpose of internal storage of the parser. Unlike `namedtuple._asdict`, it is not exposed to the user.

The purpose of changing the default to OrderedDict in the past is not documented but implying from its properties we can deduce it was to make minimal edits to .ini files stable. This property will remain unchanged with changing the type back to `dict`.

The history here is this:
- a `dict_type` was introduced by MvL in r52908 (issue 1371075) with the motivation to allow sorting or order preservation (December 2006);
- the default `dict_type` was changed by Raymond to OrderedDict for 3.1 in 0663a1ed793c164fb11d3dd62bebc677e260891e (March 2009); as far as I can tell there was no issue for it when that change was made.

I acknowledge that in https://bugs.python.org/issue32360 Raymond states that "can't just change the default argument for configparser" but I don't see why. ConfigParser doesn't return the dictionary to the user in any API and the new 3.6+ dictionary preserves order just as OrderedDict.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33504>
_______________________________________


More information about the Python-bugs-list mailing list