8000 bpo-31129: Split RawConfigParser.items() in to two methods by OddBloke · Pull Request #3012 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-31129: Split RawConfigParser.items() in to two methods #3012

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
bpo-31129: Update configparser code to use new section_items() method
  • Loading branch information
Daniel Watkins committed Aug 7, 2017
commit d28bd9920f845e3d044f390713f8d0dc1a959d8d
3 changes: 2 additions & 1 deletion Lib/configparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,8 @@ def _interpolate_some(self, parser, option, accum, rest, section, map,
option, section, rawval, ":".join(path)) from None
if "$" in v:
self._interpolate_some(parser, opt, accum, v, sect,
dict(parser.items(sect, raw=True)),
dict(parser.section_items(
sect, raw=True)),
depth + 1)
else:
accum.append(v)
Expand Down
12 changes: 6 additions & 6 deletions Lib/test/test_configparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def basic_test(self, cf):
L.sort()
eq = self.assertEqual
eq(L, E)
L = cf.items('Spacey Bar From The Beginning')
L = cf.section_items('Spacey Bar From The Beginning')
L.sort()
eq(L, F)

Expand Down Expand Up @@ -775,11 +775,11 @@ def check_items_config(self, expected):
key{0[1]} |%(name)s|
getdefault{0[1]} |%(default)s|
""".format(self.delimiters), defaults={"default": "<default>"})
L = list(cf.items("section", vars={'value': 'value'}))
L = list(cf.section_items("section", vars={'value': 'value'}))
L.sort()
self.assertEqual(L, expected)
with self.assertRaises(configparser.NoSectionError):
cf.items("no such section")
cf.section_items("no such section")

def test_popitem(self):
cf = self.fromstring("""
Expand Down Expand Up @@ -1321,10 +1321,10 @@ def test_cfgparser_dot_3(self):
longname = 'yeah, sections can be indented as well'
self.assertFalse(cf.getboolean(longname, 'are they subsections'))
self.assertEqual(cf.get(longname, 'lets use some Unicode'), '片仮名')
self.assertEqual(len(cf.items('another one!')), 5) # 4 in section and
# `go` from DEFAULT
# 4 in section and `go` from DEFAULT
self.assertEqual(len(cf.section_items('another one!')), 5)
with self.assertRaises(configparser.InterpolationMissingOptionError):
cf.items('no values here')
cf.section_items('no values here')
self.assertEqual(cf.get('tricky interpolation', 'lets'), 'do this')
self.assertEqual(cf.get('tricky interpolation', 'lets'),
cf.get('tricky interpolation', 'go'))
Expand Down
0