Let configparser use ordered dicts by default.

This commit is contained in:
Raymond Hettinger 2009-03-02 23:06:00 +00:00
parent 6accb988a1
commit 0663a1ed79
3 changed files with 13 additions and 1 deletions

View file

@ -64,6 +64,9 @@ write-back, as will be the keys within each section.
options within a section, and for the default values. This class does not options within a section, and for the default values. This class does not
support the magical interpolation behavior. support the magical interpolation behavior.
.. versionchanged 3.1
The default *dict_type* is :class:`collections.OrderedDict`.
.. class:: ConfigParser([defaults[, dict_type]]) .. class:: ConfigParser([defaults[, dict_type]])
@ -80,6 +83,9 @@ write-back, as will be the keys within each section.
option names to lower case), the values ``foo %(bar)s`` and ``foo %(BAR)s`` are option names to lower case), the values ``foo %(bar)s`` and ``foo %(BAR)s`` are
equivalent. equivalent.
.. versionchanged 3.1
The default *dict_type* is :class:`collections.OrderedDict`.
.. class:: SafeConfigParser([defaults[, dict_type]]) .. class:: SafeConfigParser([defaults[, dict_type]])
@ -90,6 +96,9 @@ write-back, as will be the keys within each section.
.. XXX Need to explain what's safer/more predictable about it. .. XXX Need to explain what's safer/more predictable about it.
.. versionchanged 3.1
The default *dict_type* is :class:`collections.OrderedDict`.
.. exception:: NoSectionError .. exception:: NoSectionError

View file

@ -88,6 +88,7 @@ ConfigParser -- responsible for parsing a list of
""" """
import re import re
from collections import OrderedDict
__all__ = ["NoSectionError", "DuplicateSectionError", "NoOptionError", __all__ = ["NoSectionError", "DuplicateSectionError", "NoOptionError",
"InterpolationError", "InterpolationDepthError", "InterpolationError", "InterpolationDepthError",
@ -215,7 +216,7 @@ class MissingSectionHeaderError(ParsingError):
class RawConfigParser: class RawConfigParser:
def __init__(self, defaults=None, dict_type=dict): def __init__(self, defaults=None, dict_type=OrderedDict):
self._dict = dict_type self._dict = dict_type
self._sections = self._dict() self._sections = self._dict()
self._defaults = self._dict() self._defaults = self._dict()

View file

@ -179,6 +179,8 @@ Library
- The _asdict() for method for namedtuples now returns an OrderedDict(). - The _asdict() for method for namedtuples now returns an OrderedDict().
- configparser now defaults to using an ordered dictionary.
- Issue #1733986: Fixed mmap crash in accessing elements of second map object - Issue #1733986: Fixed mmap crash in accessing elements of second map object
with same tagname but larger size than first map. (Windows) with same tagname but larger size than first map. (Windows)