Skip to content

Commit 1465308

Browse files
committed
Refactor to allow strict to still be set in kwargs
1 parent 779f4ab commit 1465308

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

supervisor/options.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1716,17 +1716,15 @@ class UnhosedConfigParser(ConfigParser.RawConfigParser):
17161716
mysection = 'supervisord'
17171717

17181718
def __init__(self, *args, **kwargs):
1719-
# inline_comment_prefixes was added in Python 3 but its default makes
1720-
# RawConfigParser behave differently than it did on Python 2. This
1721-
# makes it behave the same by default on Python 2 and 3.
1722-
if (not PY2) and ('inline_comment_prefixes' not in kwargs):
1723-
kwargs['inline_comment_prefixes'] = (';', '#')
1724-
1725-
# strict was added in Python 3 but its default makes RawConfigParser
1726-
# behave differently than it did on Python 2. This makes it behave
1727-
# the same by default on Python 2 and 3.
1719+
# inline_comment_prefixes and strict were added in Python 3 but their
1720+
# defaults make RawConfigParser behave differently than it did on
1721+
# Python 2. We make it work like 2 by default for backwards compat.
17281722
if not PY2:
1729-
kwargs['strict'] = False
1723+
if 'inline_comment_prefixes' not in kwargs:
1724+
kwargs['inline_comment_prefixes'] = (';', '#')
1725+
1726+
if 'strict' not in kwargs:
1727+
kwargs['strict'] = False
17301728

17311729
ConfigParser.RawConfigParser.__init__(self, *args, **kwargs)
17321730

supervisor/tests/test_options.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ def test_options_ignores_inline_comments(self):
316316
options = instance.configroot.supervisorctl
317317
self.assertEqual(options.serverurl, 'http://localhost:9001')
318318

319-
def test_options_parsers_as_nonstrict_for_py2_py3_compat(self):
319+
def test_options_parses_as_nonstrict_for_py2_py3_compat(self):
320320
text = lstrip("""
321321
[supervisorctl]
322322
serverurl=http://localhost:9001 ;duplicate
@@ -703,7 +703,7 @@ def test_options_ignores_inline_comments(self):
703703
options = instance.configroot.supervisord
704704
self.assertEqual(options.identifier, 'foo')
705705

706-
def test_options_parsers_as_nonstrict_for_py2_py3_compat(self):
706+
def test_options_parses_as_nonstrict_for_py2_py3_compat(self):
707707
text = lstrip("""
708708
[supervisord]
709709

0 commit comments

Comments
 (0)