[Python-checkins] r70122 - in python/trunk: Doc/library/configparser.rst Lib/ConfigParser.py Misc/NEWS
raymond.hettinger
python-checkins at python.org
Tue Mar 3 06:00:38 CET 2009
Author: raymond.hettinger
Date: Tue Mar 3 06:00:37 2009
New Revision: 70122
Log:
Backport 70111: Let configparser use ordered dicts by default.
Modified:
python/trunk/Doc/library/configparser.rst
python/trunk/Lib/ConfigParser.py
python/trunk/Misc/NEWS
Modified: python/trunk/Doc/library/configparser.rst
==============================================================================
--- python/trunk/Doc/library/configparser.rst (original)
+++ python/trunk/Doc/library/configparser.rst Tue Mar 3 06:00:37 2009
@@ -75,6 +75,9 @@
.. versionchanged:: 2.6
*dict_type* was added.
+ .. versionchanged:: 2.7
+ The default *dict_type* is :class:`collections.OrderedDict`.
+
.. class:: ConfigParser([defaults[, dict_type]])
@@ -91,6 +94,14 @@
option names to lower case), the values ``foo %(bar)s`` and ``foo %(BAR)s`` are
equivalent.
+ .. versionadded:: 2.3
+
+ .. versionchanged:: 2.6
+ *dict_type* was added.
+
+ .. versionchanged:: 2.7
+ The default *dict_type* is :class:`collections.OrderedDict`.
+
.. class:: SafeConfigParser([defaults[, dict_type]])
@@ -103,6 +114,12 @@
.. versionadded:: 2.3
+ .. versionchanged:: 2.6
+ *dict_type* was added.
+
+ .. versionchanged:: 2.7
+ The default *dict_type* is :class:`collections.OrderedDict`.
+
.. exception:: NoSectionError
Modified: python/trunk/Lib/ConfigParser.py
==============================================================================
--- python/trunk/Lib/ConfigParser.py (original)
+++ python/trunk/Lib/ConfigParser.py Tue Mar 3 06:00:37 2009
@@ -87,6 +87,12 @@
write the configuration state in .ini format
"""
+try:
+ from collections import OrderedDict as _default_dict
+except ImportError:
+ # fallback for setup.py which hasn't yet built _collections
+ _default_dict = dict
+
import re
__all__ = ["NoSectionError", "DuplicateSectionError", "NoOptionError",
@@ -215,7 +221,7 @@
class RawConfigParser:
- def __init__(self, defaults=None, dict_type=dict):
+ def __init__(self, defaults=None, dict_type=_default_dict):
self._dict = dict_type
self._sections = self._dict()
self._defaults = self._dict()
Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS (original)
+++ python/trunk/Misc/NEWS Tue Mar 3 06:00:37 2009
@@ -172,6 +172,8 @@
- The _asdict() for method for namedtuples now returns an OrderedDict().
+- The configparser module now defaults to using an ordered dictionary.
+
- Issue #4308: httplib.IncompleteRead's repr doesn't include all of the data all
ready received.
More information about the Python-checkins
mailing list