Rev 5988: (vila) Properly load utf8-encoded config files (Vincent Ladeuil) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Mon Jun 20 10:46:27 UTC 2011
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 5988 [merge]
revision-id: pqm at pqm.ubuntu.com-20110620104625-ih5t1e8w288pc4l2
parent: pqm at pqm.ubuntu.com-20110619183340-ds1rpql77nxrmo4n
parent: v.ladeuil+lp at free.fr-20110620093117-8o1ytb8hoemgq710
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Mon 2011-06-20 10:46:25 +0000
message:
(vila) Properly load utf8-encoded config files (Vincent Ladeuil)
modified:
bzrlib/config.py config.py-20051011043216-070c74f4e9e338e8
bzrlib/tests/test_config.py testconfig.py-20051011041908-742d0c15d8d8c8eb
doc/en/release-notes/bzr-2.4.txt bzr2.4.txt-20110114053217-k7ym9jfz243fddjm-1
=== modified file 'bzrlib/config.py'
--- a/bzrlib/config.py 2011-06-19 02:48:01 +0000
+++ b/bzrlib/config.py 2011-06-20 09:31:17 +0000
@@ -2375,13 +2375,10 @@
:param str_or_unicode: A string representing the file content. This will
be utf-8 encoded internally.
-
- This is for tests and should not be used in production unless a
- convincing use case can be demonstrated :)
"""
if self.is_loaded():
raise AssertionError('Already loaded: %r' % (self._config_obj,))
- co_input = StringIO(str_or_unicode.encode('utf-8'))
+ co_input = StringIO(str_or_unicode)
try:
# The config files are always stored utf8-encoded
self._config_obj = ConfigObj(co_input, encoding='utf-8')
=== modified file 'bzrlib/tests/test_config.py'
--- a/bzrlib/tests/test_config.py 2011-06-14 10:07:16 +0000
+++ b/bzrlib/tests/test_config.py 2011-06-20 09:31:17 +0000
@@ -2328,6 +2328,22 @@
self.assertRaises(AssertionError, store._load_from_string, 'bar=baz')
+class TestBug799212(TestStore):
+
+ def test_load_utf8(self):
+ t = self.get_transport()
+ # From http://pad.lv/799212
+ unicode_user = u'Piotr O\u017carowski'
+ unicode_content = u'user=%s' % (unicode_user,)
+ utf8_content = unicode_content.encode('utf8')
+ # Store the raw content in the config file
+ t.put_bytes('foo.conf', utf8_content)
+ store = config.IniFileStore(t, 'foo.conf')
+ store.load()
+ stack = config.Stack([store.get_sections], store)
+ self.assertEquals(unicode_user, stack.get('user'))
+
+
class TestMutableStore(TestStore):
scenarios = [(key, {'store_id': key, 'get_store': builder}) for key, builder
=== modified file 'doc/en/release-notes/bzr-2.4.txt'
--- a/doc/en/release-notes/bzr-2.4.txt 2011-06-18 13:57:17 +0000
+++ b/doc/en/release-notes/bzr-2.4.txt 2011-06-20 09:31:17 +0000
@@ -29,6 +29,8 @@
Bug Fixes
*********
+* Properly load utf8-encoded config files. (Vincent Ladeuil, #799212)
+
.. Fixes for situations where bzr would previously crash or give incorrect
or undesirable results.
More information about the bazaar-commits
mailing list