]> granicus.if.org Git - python/commitdiff
Let configparser use ordered dicts by default.
authorRaymond Hettinger <python@rcn.com>
Mon, 2 Mar 2009 23:06:00 +0000 (23:06 +0000)
committerRaymond Hettinger <python@rcn.com>
Mon, 2 Mar 2009 23:06:00 +0000 (23:06 +0000)
Doc/library/configparser.rst
Lib/configparser.py
Misc/NEWS

index e833e23ed9fdadb7ea71b26662fc3a5f4916609d..9439d0de477a1cdc0b26590743f72aa1da6f7dfb 100644 (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
    support the magical interpolation behavior.
 
+   .. versionchanged 3.1
+      The default *dict_type* is :class:`collections.OrderedDict`.
+
 
 .. 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
    equivalent.
 
+   .. versionchanged 3.1
+      The default *dict_type* is :class:`collections.OrderedDict`.
+
 
 .. 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.
 
+   .. versionchanged 3.1
+      The default *dict_type* is :class:`collections.OrderedDict`.
+
 
 .. exception:: NoSectionError
 
index 5e36cc96008b9e7977600bab134ea2134b4b7968..f2e644c1add0bf7748997ae91850166e803bd636 100644 (file)
@@ -88,6 +88,7 @@ ConfigParser -- responsible for parsing a list of
 """
 
 import re
+from collections import OrderedDict
 
 __all__ = ["NoSectionError", "DuplicateSectionError", "NoOptionError",
            "InterpolationError", "InterpolationDepthError",
@@ -215,7 +216,7 @@ class MissingSectionHeaderError(ParsingError):
 
 
 class RawConfigParser:
-    def __init__(self, defaults=None, dict_type=dict):
+    def __init__(self, defaults=None, dict_type=OrderedDict):
         self._dict = dict_type
         self._sections = self._dict()
         self._defaults = self._dict()
index 7a3c96f4a7dcd21e15b2717f55723c292bdfb29c..91c94fff6a4a374a912ba3c37eb8fee700004eb9 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -179,6 +179,8 @@ Library
 
 - 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
   with same tagname but larger size than first map. (Windows)