The attached patch fixes this issue.

Cheers,

Jelmer
Index: debian/patches/triplequotes.diff
===================================================================
--- debian/patches/triplequotes.diff	(revision 0)
+++ debian/patches/triplequotes.diff	(revision 0)
@@ -0,0 +1,65 @@
+Description: write out the right kind of triple quotes
+Author: Alexander Belchenko
+Origin: cherrypicked from Bazaar's trunk, commit:[email protected]
+Bug: http://code.google.com/p/configobj/issues?detail?id=31
+Bug-Debian: http://bugs.debian.org/618349
+
+diff -ur configobj-4.7.2/configobj.py configobj-4.7.2.new/configobj.py
+--- configobj-4.7.2/configobj.py	2011-03-14 17:09:10.000000000 +0100
++++ configobj-4.7.2.new/configobj.py	2011-03-14 17:09:53.000000000 +0100
+@@ -1817,9 +1817,9 @@
+         if (value.find('"""') != -1) and (value.find("'''") != -1):
+             raise ConfigObjError('Value "%s" cannot be safely quoted.' % value)
+         if value.find('"""') == -1:
+-            quot = tdquot
++            quot = tsquot
+         else:
+-            quot = tsquot 
++            quot = tdquot
+         return quot
+ 
+ 
+diff -ur configobj-4.7.2/tests/functionaltests/test_configobj.py configobj-4.7.2.new/tests/functionaltests/test_configobj.py
+--- configobj-4.7.2/tests/functionaltests/test_configobj.py	2011-03-14 17:09:10.000000000 +0100
++++ configobj-4.7.2.new/tests/functionaltests/test_configobj.py	2011-03-14 17:10:09.000000000 +0100
+@@ -7,6 +7,7 @@
+     import unittest
+ 
+ from configobj import ConfigObj
++from StringIO import StringIO
+ 
+ try:
+     # Python 2.6 only
+@@ -99,6 +100,19 @@
+         # This raises a MissingInterpolationOption exception in 4.7.1 and earlier
+         repr(c)
+ 
++    def test_triple_quotes(self):
++        triple_quotes_value = '''spam
++""" that's my spam """
++eggs'''
++        co = ConfigObj()
++        co['test'] = triple_quotes_value
++        outfile = StringIO()
++        co.write(outfile=outfile)
++        lines = outfile.getvalue().splitlines()
++        # now we're trying to read it back
++        co2 = ConfigObj(lines)
++        self.assertEquals(triple_quotes_value, co2['test'])
++
+     def test_as_functions(self):
+         a = ConfigObj()
+         a['a'] = 'fish'
+--- configobj-4.7.2/tests/test_configobj.py	2011-03-14 17:09:19.000000000 +0100
++++ configobj-4.7.2.new/tests/test_configobj.py	2011-03-14 17:16:18.000000000 +0100
+@@ -374,7 +374,6 @@ def _doctest():
+     >>> cfg.write()
+-    ["key1 = '''Multiline\\nValue'''", 'key2 = "Value" with \\'quotes\\' !']
++    ['key1 = \"\"\"Multiline\\nValue\"\"\"', 'key2 = "Value" with \\'quotes\\' !']
+     >>> cfg.list_values = True
+-    >>> cfg.write() == ["key1 = '''Multiline\\nValue'''",
+-    ... 'key2 = \\'\\'\\'"Value" with \\'quotes\\' !\\'\\'\\'']
+-    1
++    >>> cfg.write()
++    ['key1 = \"\"\"Multiline\\nValue\"\"\"', 'key2 = \"\"\""Value" with \\'quotes\\' !\"\"\"']
+     
Index: debian/patches/series
===================================================================
--- debian/patches/series	(revision 16119)
+++ debian/patches/series	(working copy)
@@ -1,3 +1,4 @@
 eggify.diff
 report-doctest-failure.diff
 py27-test.diff
+triplequotes.diff
Index: debian/changelog
===================================================================
--- debian/changelog	(revision 16119)
+++ debian/changelog	(working copy)
@@ -1,5 +1,6 @@
 configobj (4.7.2+ds-2) UNRELEASED; urgency=low
 
+  [ Stefano Rivera ]
   * Don't leak uid and umask into source tarball and set -e.
   * Bumped Standards-Version to 3.9.1 (no changes needed).
   * Enable test suites.
@@ -15,8 +16,11 @@
   * Update my e-mail address.
   * Use DEP5 format in debian/copyright.
 
- -- Stefano Rivera <[email protected]>  Sat, 05 Feb 2011 12:14:08 +0200
+  [ Jelmer Vernooij ]
+  * Properly handle triple quotes. Closes: #618349, LP: #710410
 
+ -- Jelmer Vernooij <[email protected]>  Mon, 14 Mar 2011 16:57:05 +0100
+
 configobj (4.7.2+ds-1) unstable; urgency=low
 
   * New upstream release.

Attachment: signature.asc
Description: Digital signature

Reply via email to