[Python-checkins] r70111 - in python/branches/py3k: Doc/library/configparser.rst Lib/configparser.py Misc/NEWS

raymond.hettinger python-checkins at python.org
Tue Mar 3 00:06:11 CET 2009


Author: raymond.hettinger
Date: Tue Mar  3 00:06:00 2009
New Revision: 70111

Log:
Let configparser use ordered dicts by default.

Modified:
   python/branches/py3k/Doc/library/configparser.rst
   python/branches/py3k/Lib/configparser.py
   python/branches/py3k/Misc/NEWS

Modified: python/branches/py3k/Doc/library/configparser.rst
==============================================================================
--- python/branches/py3k/Doc/library/configparser.rst	(original)
+++ python/branches/py3k/Doc/library/configparser.rst	Tue Mar  3 00:06:00 2009
@@ -64,6 +64,9 @@
    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 @@
    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 @@
 
    .. XXX Need to explain what's safer/more predictable about it.
 
+   .. versionchanged 3.1
+      The default *dict_type* is :class:`collections.OrderedDict`.
+
 
 .. exception:: NoSectionError
 

Modified: python/branches/py3k/Lib/configparser.py
==============================================================================
--- python/branches/py3k/Lib/configparser.py	(original)
+++ python/branches/py3k/Lib/configparser.py	Tue Mar  3 00:06:00 2009
@@ -88,6 +88,7 @@
 """
 
 import re
+from collections import OrderedDict
 
 __all__ = ["NoSectionError", "DuplicateSectionError", "NoOptionError",
            "InterpolationError", "InterpolationDepthError",
@@ -215,7 +216,7 @@
 
 
 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()

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Tue Mar  3 00:06:00 2009
@@ -179,6 +179,8 @@
 
 - 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)
 


More information about the Python-checkins mailing list