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
33cd058f
Commit
33cd058f
authored
Jun 12, 2018
by
Cheryl Sabella
Committed by
Łukasz Langa
Jun 12, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-32108: Don't clear configparser values if key is assigned to itself (GH-7588)
parent
c3f55be7
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
1 deletion
+9
-1
Lib/configparser.py
Lib/configparser.py
+2
-1
Lib/test/test_configparser.py
Lib/test/test_configparser.py
+6
-0
Misc/NEWS.d/next/Library/2018-06-10-12-15-26.bpo-32108.iEkvh0.rst
...S.d/next/Library/2018-06-10-12-15-26.bpo-32108.iEkvh0.rst
+1
-0
No files found.
Lib/configparser.py
View file @
33cd058f
...
...
@@ -963,7 +963,8 @@ class RawConfigParser(MutableMapping):
def __setitem__(self, key, value):
# To conform with the mapping protocol, overwrites existing values in
# the section.
if key in self and self[key] is value:
return
# XXX this is not atomic if read_dict fails at any point. Then again,
# no update method in configparser is atomic in this implementation.
if key == self.default_section:
...
...
Lib/test/test_configparser.py
View file @
33cd058f
...
...
@@ -850,12 +850,18 @@ boolean {0[0]} NO
self
.
assertEqual
(
set
(
cf
[
'section3'
].
keys
()),
{
'named'
})
self
.
assertNotIn
(
'name3'
,
cf
[
'section3'
])
self
.
assertEqual
(
cf
.
sections
(),
[
'section1'
,
'section2'
,
'section3'
])
# For bpo-32108, assigning default_section to itself.
cf
[
self
.
default_section
]
=
cf
[
self
.
default_section
]
self
.
assertNotEqual
(
set
(
cf
[
self
.
default_section
].
keys
()),
set
())
cf
[
self
.
default_section
]
=
{}
self
.
assertEqual
(
set
(
cf
[
self
.
default_section
].
keys
()),
set
())
self
.
assertEqual
(
set
(
cf
[
'section1'
].
keys
()),
{
'name1'
})
self
.
assertEqual
(
set
(
cf
[
'section2'
].
keys
()),
{
'name22'
})
self
.
assertEqual
(
set
(
cf
[
'section3'
].
keys
()),
set
())
self
.
assertEqual
(
cf
.
sections
(),
[
'section1'
,
'section2'
,
'section3'
])
# For bpo-32108, assigning section to itself.
cf
[
'section2'
]
=
cf
[
'section2'
]
self
.
assertEqual
(
set
(
cf
[
'section2'
].
keys
()),
{
'name22'
})
def
test_invalid_multiline_value
(
self
):
if
self
.
allow_no_value
:
...
...
Misc/NEWS.d/next/Library/2018-06-10-12-15-26.bpo-32108.iEkvh0.rst
0 → 100644
View file @
33cd058f
In configparser, don't clear section when it is assigned to itself.
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