Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
0663a1ed
Commit
0663a1ed
authored
Mar 02, 2009
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Let configparser use ordered dicts by default.
parent
6accb988
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
1 deletion
+13
-1
Doc/library/configparser.rst
Doc/library/configparser.rst
+9
-0
Lib/configparser.py
Lib/configparser.py
+2
-1
Misc/NEWS
Misc/NEWS
+2
-0
No files found.
Doc/library/configparser.rst
View file @
0663a1ed
...
...
@@ -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
...
...
Lib/configparser.py
View file @
0663a1ed
...
...
@@ -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
=
d
ict
):
def
__init__
(
self
,
defaults
=
None
,
dict_type
=
OrderedD
ict
):
self
.
_dict
=
dict_type
self
.
_sections
=
self
.
_dict
()
self
.
_defaults
=
self
.
_dict
()
...
...
Misc/NEWS
View file @
0663a1ed
...
...
@@ -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)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment