Merge lp:~bialix/bzr/2.3-configobj into lp:bzr/2.3

Proposed by Alexander Belchenko
Status: Merged
Approved by: Martin Pool
Approved revision: no longer in the source branch.
Merged at revision: 5623
Proposed branch: lp:~bialix/bzr/2.3-configobj
Merge into: lp:bzr/2.3
Diff against target: 75 lines (+35/-3)
3 files modified
bzrlib/tests/test_config.py (+27/-1)
bzrlib/util/configobj/configobj.py (+4/-2)
doc/en/release-notes/bzr-2.2.txt (+4/-0)
To merge this branch: bzr merge lp:~bialix/bzr/2.3-configobj
Reviewer Review Type Date Requested Status
Martin Pool Approve
Review via email: mp+50511@code.launchpad.net

Description of the change

This branch has the same fix as lp:~bialix/bzr/2.2-configobj, see MP: https://code.launchpad.net/~bialix/bzr/2.2-configobj/+merge/50507 but now it's prepared for inclusion into 2.3 series. I've fixed merge conflict of NEWS entry, there is no other changes.

To post a comment you must log in.
Revision history for this message
Martin Pool (mbp) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bzrlib/tests/test_config.py'
--- bzrlib/tests/test_config.py 2011-01-10 22:20:12 +0000
+++ bzrlib/tests/test_config.py 2011-02-22 09:51:57 +0000
@@ -309,11 +309,37 @@
309 """309 """
310 co = config.ConfigObj()310 co = config.ConfigObj()
311 co['test'] = 'foo#bar'311 co['test'] = 'foo#bar'
312 lines = co.write()312 outfile = StringIO()
313 co.write(outfile=outfile)
314 lines = outfile.getvalue().splitlines()
313 self.assertEqual(lines, ['test = "foo#bar"'])315 self.assertEqual(lines, ['test = "foo#bar"'])
314 co2 = config.ConfigObj(lines)316 co2 = config.ConfigObj(lines)
315 self.assertEqual(co2['test'], 'foo#bar')317 self.assertEqual(co2['test'], 'foo#bar')
316318
319 def test_triple_quotes(self):
320 # Bug #710410: if the value string has triple quotes
321 # then ConfigObj versions up to 4.7.2 will quote them wrong
322 # and won't able to read them back
323 triple_quotes_value = '''spam
324""" that's my spam """
325eggs'''
326 co = config.ConfigObj()
327 co['test'] = triple_quotes_value
328 # While writing this test another bug in ConfigObj has been found:
329 # method co.write() without arguments produces list of lines
330 # one option per line, and multiline values are not split
331 # across multiple lines,
332 # and that breaks the parsing these lines back by ConfigObj.
333 # This issue only affects test, but it's better to avoid
334 # `co.write()` construct at all.
335 # [bialix 20110222] bug report sent to ConfigObj's author
336 outfile = StringIO()
337 co.write(outfile=outfile)
338 output = outfile.getvalue()
339 # now we're trying to read it back
340 co2 = config.ConfigObj(StringIO(output))
341 self.assertEquals(triple_quotes_value, co2['test'])
342
317343
318erroneous_config = """[section] # line 1344erroneous_config = """[section] # line 1
319good=good # line 2345good=good # line 2
320346
=== modified file 'bzrlib/util/configobj/configobj.py'
--- bzrlib/util/configobj/configobj.py 2009-04-17 22:24:54 +0000
+++ bzrlib/util/configobj/configobj.py 2011-02-22 09:51:57 +0000
@@ -1794,10 +1794,12 @@
1794 def _get_triple_quote(self, value):1794 def _get_triple_quote(self, value):
1795 if (value.find('"""') != -1) and (value.find("'''") != -1):1795 if (value.find('"""') != -1) and (value.find("'''") != -1):
1796 raise ConfigObjError('Value "%s" cannot be safely quoted.' % value)1796 raise ConfigObjError('Value "%s" cannot be safely quoted.' % value)
1797 # upstream version (up to version 4.7.2) has the bug with incorrect quoting;
1798 # fixed in our copy based on the suggestion of ConfigObj's author
1797 if value.find('"""') == -1:1799 if value.find('"""') == -1:
1800 quot = tsquot
1801 else:
1798 quot = tdquot1802 quot = tdquot
1799 else:
1800 quot = tsquot
1801 return quot1803 return quot
18021804
18031805
18041806
=== modified file 'doc/en/release-notes/bzr-2.2.txt'
--- doc/en/release-notes/bzr-2.2.txt 2011-02-09 08:24:25 +0000
+++ doc/en/release-notes/bzr-2.2.txt 2011-02-22 09:51:57 +0000
@@ -36,6 +36,10 @@
36Internals36Internals
37*********37*********
3838
39* Fixed bug in the bundled copy of ConfigObj with quoting of triple quotes
40 in the value string. Fix suggested by ConfigObj's author Michael Foord.
41 (Alexander Belchenko, #710410)
42
39Testing43Testing
40*******44*******
4145

Subscribers

People subscribed via source and target branches