Rev 5990: Proper message when authentication.conf has non-utf8 content in file:///home/vila/src/bzr/bugs/799212-non-ascii-confs/

Vincent Ladeuil v.ladeuil+lp at free.fr
Mon Jun 20 13:15:31 UTC 2011


At file:///home/vila/src/bzr/bugs/799212-non-ascii-confs/

------------------------------------------------------------
revno: 5990
revision-id: v.ladeuil+lp at free.fr-20110620131531-6lozjugg9hwf5qp2
parent: v.ladeuil+lp at free.fr-20110620130257-qxa7bzkhcufk0v58
fixes bug(s): https://launchpad.net/bugs/792246
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 799212-non-ascii-confs
timestamp: Mon 2011-06-20 15:15:31 +0200
message:
  Proper message when authentication.conf has non-utf8 content
-------------- next part --------------
=== modified file 'bzrlib/config.py'
--- a/bzrlib/config.py	2011-06-20 09:31:17 +0000
+++ b/bzrlib/config.py	2011-06-20 13:15:31 +0000
@@ -1697,6 +1697,8 @@
             self._config = ConfigObj(self._input, encoding='utf-8')
         except configobj.ConfigObjError, e:
             raise errors.ParseConfigError(e.errors, e.config.filename)
+        except UnicodeError, e:
+            raise errors.ConfigContentError(self._filename)
         return self._config
 
     def _save(self):

=== modified file 'bzrlib/errors.py'
--- a/bzrlib/errors.py	2011-06-02 16:57:09 +0000
+++ b/bzrlib/errors.py	2011-06-20 13:15:31 +0000
@@ -1770,6 +1770,15 @@
     _fmt = "Working tree has conflicts."
 
 
+class ConfigContentError(BzrError):
+
+    _fmt = "Config file %(filename)s is not UTF-8 encoded\n"
+
+    def __init__(self, filename):
+        BzrError.__init__(self)
+        self.filename = filename
+
+
 class ParseConfigError(BzrError):
 
     _fmt = "Error(s) parsing config file %(filename)s:\n%(errors)s"

=== modified file 'bzrlib/tests/test_config.py'
--- a/bzrlib/tests/test_config.py	2011-06-20 13:02:57 +0000
+++ b/bzrlib/tests/test_config.py	2011-06-20 13:15:31 +0000
@@ -3117,7 +3117,7 @@
     def test_non_utf8_config(self):
         conf = config.AuthenticationConfig(_file=StringIO(
                 'foo = bar\xff'))
-        self.assertRaises(errors.ParseConfigError, conf._get_config)
+        self.assertRaises(errors.ConfigContentError, conf._get_config)
         
     def test_missing_auth_section_header(self):
         conf = config.AuthenticationConfig(_file=StringIO('foo = bar'))

=== modified file 'doc/en/release-notes/bzr-2.4.txt'
--- a/doc/en/release-notes/bzr-2.4.txt	2011-06-20 09:31:17 +0000
+++ b/doc/en/release-notes/bzr-2.4.txt	2011-06-20 13:15:31 +0000
@@ -29,6 +29,9 @@
 Bug Fixes
 *********
 
+* Display a proper error message when ``authentication.conf`` content cannot
+  be decoded as UTF-8. (Vincent Ladeuil, #792246)
+
 * Properly load utf8-encoded config files. (Vincent Ladeuil, #799212)
 
 .. Fixes for situations where bzr would previously crash or give incorrect



More information about the bazaar-commits mailing list