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
70eb79c6
Commit
70eb79c6
authored
Apr 28, 2011
by
Łukasz Langa
Browse files
Options
Browse Files
Download
Plain Diff
Merged solution for #11324 from 3.2.
parents
bf53a9c2
1aa422fe
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
4 deletions
+44
-4
Lib/configparser.py
Lib/configparser.py
+5
-4
Lib/test/test_configparser.py
Lib/test/test_configparser.py
+38
-0
Misc/ACKS
Misc/ACKS
+1
-0
No files found.
Lib/configparser.py
View file @
70eb79c6
...
...
@@ -624,11 +624,12 @@ class RawConfigParser(MutableMapping):
self._strict = strict
self._allow_no_value = allow_no_value
self._empty_lines_in_values = empty_lines_in_values
if interpolation is _UNSET:
self._interpolation = self._DEFAULT_INTERPOLATION
else:
self._interpolation = interpolation
self.default_section=default_section
self._interpolation = interpolation
if self._interpolation is _UNSET:
self._interpolation = self._DEFAULT_INTERPOLATION
if self._interpolation is None:
self._interpolation = Interpolation()
def defaults(self):
return self._defaults
...
...
Lib/test/test_configparser.py
View file @
70eb79c6
...
...
@@ -864,6 +864,43 @@ class ConfigParserTestCase(BasicTestCase):
cf
=
self
.
newconfig
()
self
.
assertRaises
(
ValueError
,
cf
.
add_section
,
self
.
default_section
)
class
ConfigParserTestCaseNoInterpolation
(
BasicTestCase
):
config_class
=
configparser
.
ConfigParser
interpolation
=
None
ini
=
textwrap
.
dedent
(
"""
[numbers]
one = 1
two = %(one)s * 2
three = ${common:one} * 3
[hexen]
sixteen = ${numbers:two} * 8
"""
).
strip
()
def
assertMatchesIni
(
self
,
cf
):
self
.
assertEqual
(
cf
[
'numbers'
][
'one'
],
'1'
)
self
.
assertEqual
(
cf
[
'numbers'
][
'two'
],
'%(one)s * 2'
)
self
.
assertEqual
(
cf
[
'numbers'
][
'three'
],
'${common:one} * 3'
)
self
.
assertEqual
(
cf
[
'hexen'
][
'sixteen'
],
'${numbers:two} * 8'
)
def
test_no_interpolation
(
self
):
cf
=
self
.
fromstring
(
self
.
ini
)
self
.
assertMatchesIni
(
cf
)
def
test_empty_case
(
self
):
cf
=
self
.
newconfig
()
self
.
assertIsNone
(
cf
.
read_string
(
""
))
def
test_none_as_default_interpolation
(
self
):
class
CustomConfigParser
(
configparser
.
ConfigParser
):
_DEFAULT_INTERPOLATION
=
None
cf
=
CustomConfigParser
()
cf
.
read_string
(
self
.
ini
)
self
.
assertMatchesIni
(
cf
)
class
ConfigParserTestCaseLegacyInterpolation
(
ConfigParserTestCase
):
config_class
=
configparser
.
ConfigParser
interpolation
=
configparser
.
LegacyInterpolation
()
...
...
@@ -1444,6 +1481,7 @@ def test_main():
ConfigParserTestCaseNoValue
,
ConfigParserTestCaseExtendedInterpolation
,
ConfigParserTestCaseLegacyInterpolation
,
ConfigParserTestCaseNoInterpolation
,
ConfigParserTestCaseTrickyFile
,
MultilineValuesTestCase
,
RawConfigParserTestCase
,
...
...
Misc/ACKS
View file @
70eb79c6
...
...
@@ -115,6 +115,7 @@ Terrence Brannon
Brian Brazil
Dave Brennan
Tom Bridgman
Tobias Brink
Richard Brodie
Michael Broghton
Daniel Brotsky
...
...
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