diff options
author | John Reese <john@noswap.com> | 2018-06-05 16:31:33 -0700 |
---|---|---|
committer | Ćukasz Langa <lukasz@langa.pl> | 2018-06-05 16:31:33 -0700 |
commit | 3a5b0d8988491d9408b22bceea6fd70b91345724 (patch) | |
tree | aa1e6bb4b15091e203305658677251739946ede5 /Lib | |
parent | 5f3d04fa4e9b3c3b0e4807f8516de9365bfed467 (diff) | |
download | cpython-git-3a5b0d8988491d9408b22bceea6fd70b91345724.tar.gz |
bpo-33504: Migrate configparser from OrderedDict to dict. (#6819)
With 3.7+, dictionary are ordered by design. Configparser still uses
collections.OrderedDict, which is unnecessary. This updates the module
to use the standard dict implementation by default, and changes the
docs and tests to match.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/configparser.py | 3 | ||||
-rw-r--r-- | Lib/test/test_configparser.py | 2 |
2 files changed, 3 insertions, 2 deletions
diff --git a/Lib/configparser.py b/Lib/configparser.py index a681d3990e..c88605feff 100644 --- a/Lib/configparser.py +++ b/Lib/configparser.py @@ -139,7 +139,7 @@ ConfigParser -- responsible for parsing a list of """ from collections.abc import MutableMapping -from collections import OrderedDict as _default_dict, ChainMap as _ChainMap +from collections import ChainMap as _ChainMap import functools import io import itertools @@ -157,6 +157,7 @@ __all__ = ["NoSectionError", "DuplicateOptionError", "DuplicateSectionError", "LegacyInterpolation", "SectionProxy", "ConverterMapping", "DEFAULTSECT", "MAX_INTERPOLATION_DEPTH"] +_default_dict = dict DEFAULTSECT = "DEFAULT" MAX_INTERPOLATION_DEPTH = 10 diff --git a/Lib/test/test_configparser.py b/Lib/test/test_configparser.py index 87b811f09b..f4df622050 100644 --- a/Lib/test/test_configparser.py +++ b/Lib/test/test_configparser.py @@ -1109,7 +1109,7 @@ class RawConfigParserTestCase(BasicTestCase, unittest.TestCase): self.assertEqual(cf.get(123, 'this is sick'), True) if cf._dict is configparser._default_dict: # would not work for SortedDict; only checking for the most common - # default dictionary (OrderedDict) + # default dictionary (dict) cf.optionxform = lambda x: x cf.set('non-string', 1, 1) self.assertEqual(cf.get('non-string', 1), 1) |