[python/f14/master] Cherrypick following fix from f15 - backport a patch to fix a change in behaviour in configparse.

Toshio くらとみ toshio at fedoraproject.org
Thu Sep 16 17:54:55 UTC 2010


commit 1370177569970efbe85d664b230fd10b30deab5a
Author: Toshio Kuratomi <toshio at fedoraproject.org>
Date:   Thu Sep 16 13:42:05 2010 -0400

    Cherrypick following fix from f15
    - backport a patch to fix a change in behaviour in configparse.

 python-2.7-r84443-cfgparse.patch |   66 ++++++++++++++++++++++++++++++++++++++
 python.spec                      |   12 ++++++-
 2 files changed, 77 insertions(+), 1 deletions(-)
---
diff --git a/python-2.7-r84443-cfgparse.patch b/python-2.7-r84443-cfgparse.patch
new file mode 100644
index 0000000..eed6e5f
--- /dev/null
+++ b/python-2.7-r84443-cfgparse.patch
@@ -0,0 +1,66 @@
+Index: Lib/ConfigParser.py
+===================================================================
+--- Lib/ConfigParser.py.orig
++++ Lib/ConfigParser.py
+@@ -399,11 +399,10 @@ class RawConfigParser:
+             fp.write("[%s]\n" % section)
+             for (key, value) in self._sections[section].items():
+                 if key != "__name__":
+-                    if value is None:
+-                        fp.write("%s\n" % (key))
+-                    else:
+-                        fp.write("%s = %s\n" %
+-                                 (key, str(value).replace('\n', '\n\t')))
++                    if (value is not None) or (self._optcre == self.OPTCRE):
++                        key = " = ".join((key, str(value).replace('\n', '\n\t')))
++                    fp.write("%s\n" % (key))
++
+             fp.write("\n")
+ 
+     def remove_option(self, section, option):
+Index: Lib/test/test_cfgparser.py
+===================================================================
+--- Lib/test/test_cfgparser.py.orig
++++ Lib/test/test_cfgparser.py
+@@ -493,6 +493,33 @@ class SafeConfigParserTestCaseNoValue(Sa
+     allow_no_value = True
+ 
+ 
++class Issue7005TestCase(unittest.TestCase):
++    """Test output when None is set() as a value and allow_no_value == False.
++
++    http://bugs.python.org/issue7005
++
++    """
++
++    expected_output = "[section]\noption = None\n\n"
++
++    def prepare(self, config_class):
++        # This is the default, but that's the point.
++        cp = config_class(allow_no_value=False)
++        cp.add_section("section")
++        cp.set("section", "option", None)
++        sio = StringIO.StringIO()
++        cp.write(sio)
++        return sio.getvalue()
++
++    def test_none_as_value_stringified(self):
++        output = self.prepare(ConfigParser.ConfigParser)
++        self.assertEqual(output, self.expected_output)
++
++    def test_none_as_value_stringified_raw(self):
++        output = self.prepare(ConfigParser.RawConfigParser)
++        self.assertEqual(output, self.expected_output)
++
++
+ class SortedTestCase(RawConfigParserTestCase):
+     def newconfig(self, defaults=None):
+         self.cf = self.config_class(defaults=defaults, dict_type=SortedDict)
+@@ -524,6 +551,7 @@ def test_main():
+         RawConfigParserTestCase,
+         SafeConfigParserTestCase,
+         SortedTestCase,
++        Issue7005TestCase,
+         SafeConfigParserTestCaseNoValue,
+         )
+ 
diff --git a/python.spec b/python.spec
index 8be62e9..fe9d7ab 100644
--- a/python.spec
+++ b/python.spec
@@ -94,7 +94,7 @@ Summary: An interpreted, interactive, object-oriented programming language
 Name: %{python}
 # Remember to also rebase python-docs when changing this:
 Version: 2.7
-Release: 8%{?dist}
+Release: 8%{?dist}.1
 License: Python
 Group: Development/Languages
 Provides: python-abi = %{pybasever}
@@ -267,6 +267,11 @@ Patch54: python-2.6.4-setup-db48.patch
 # for 2.7rc1 by dmalcolm:
 Patch55: python-2.7rc1-dtrace.patch
 
+# Backported fix from upstream for regression in ConfigParse's handling
+# of None values
+# http://bugs.python.org/issue7005#msg115417
+Patch56: python-2.7-r84443-cfgparse.patch
+
 # "lib64 patches"
 # This patch seems to be associated with bug 122304, which was
 #  http://sourceforge.net/tracker/?func=detail&atid=105470&aid=931848&group_id=5470
@@ -656,6 +661,8 @@ rm -r Modules/zlib || exit 1
 %patch55 -p1 -b .systemtap
 %endif
 
+%patch56 -p0 -b .cfgparse
+
 %patch110 -p1 -b .selinux
 
 %patch111 -p1 -b .no-static-lib
@@ -1622,6 +1629,9 @@ rm -fr %{buildroot}
 # payload file would be unpackaged)
 
 %changelog
+* Thu Sep 16 2010 Toshio Kuratomi <toshio at fedoraproject.org> - 2.7-8.1
+- backport a patch to fix a change in behaviour in configparse.
+
 * Wed Aug 18 2010 David Malcolm <dmalcolm at redhat.com> - 2.7-8
 - add %%check section
 - update lib64 patch (patch 102) to fix expected output in test_site.py on


More information about the scm-commits mailing list