Rev 3447: Treat '' encoding as ascii in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Thu May 22 08:20:23 BST 2008


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 3447
revision-id:pqm at pqm.ubuntu.com-20080522072006-acx3ybdu09zr98ka
parent: pqm at pqm.ubuntu.com-20080521154523-4hv5qe8a9drke2h1
parent: mbp at sourcefrog.net-20080521083100-p22mu7ma60ax7evy
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2008-05-22 08:20:06 +0100
message:
  Treat '' encoding as ascii
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/osutils.py              osutils.py-20050309040759-eeaff12fbf77ac86
  bzrlib/tests/test_osutils_encodings.py test_osutils_encodin-20061226013130-kkp732tpt3lm91vv-1
    ------------------------------------------------------------
    revno: 3443.1.1
    revision-id:mbp at sourcefrog.net-20080521083100-p22mu7ma60ax7evy
    parent: pqm at pqm.ubuntu.com-20080521054623-5ayhndccwr6o45uq
    parent: nmb at wartburg.edu-20080505170202-8dwdkpzks4jshr3v
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: integration
    timestamp: Wed 2008-05-21 18:31:00 +1000
    message:
      Treat '' encoding as ascii
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/osutils.py              osutils.py-20050309040759-eeaff12fbf77ac86
      bzrlib/tests/test_osutils_encodings.py test_osutils_encodin-20061226013130-kkp732tpt3lm91vv-1
    ------------------------------------------------------------
    revno: 3405.3.1
    revision-id:nmb at wartburg.edu-20080505170202-8dwdkpzks4jshr3v
    parent: pqm at pqm.ubuntu.com-20080502230043-zwk3y5idlir4uak1
    committer: Neil Martinsen-Burrell <nmb at wartburg.edu>
    branch nick: encoding-check-change
    timestamp: Mon 2008-05-05 12:02:02 -0500
    message:
      accept  for an encoding to mean ascii
    modified:
      bzrlib/osutils.py              osutils.py-20050309040759-eeaff12fbf77ac86
      bzrlib/tests/test_osutils_encodings.py test_osutils_encodin-20061226013130-kkp732tpt3lm91vv-1
=== modified file 'NEWS'
--- a/NEWS	2008-05-21 15:45:23 +0000
+++ b/NEWS	2008-05-22 07:20:06 +0000
@@ -62,6 +62,10 @@
       them.
       (Vincent Ladeuil, #229076)
 
+    * Treat an encoding of '' as ascii; this can happen when bzr is run
+      under vim on Mac OS X.
+      (Neil Martinsen-Burrell)
+
   DOCUMENTATION:
 
     * Added directory structure and started translation of docs in spanish.

=== modified file 'bzrlib/osutils.py'
--- a/bzrlib/osutils.py	2008-05-08 04:33:38 +0000
+++ b/bzrlib/osutils.py	2008-05-21 08:31:00 +0000
@@ -1344,7 +1344,9 @@
     # Windows returns 'cp0' to indicate there is no code page. So we'll just
     # treat that as ASCII, and not support printing unicode characters to the
     # console.
-    if user_encoding in (None, 'cp0'):
+    #
+    # For python scripts run under vim, we get '', so also treat that as ASCII
+    if user_encoding in (None, 'cp0', ''):
         user_encoding = 'ascii'
     else:
         # check encoding

=== modified file 'bzrlib/tests/test_osutils_encodings.py'
--- a/bzrlib/tests/test_osutils_encodings.py	2007-11-01 09:52:45 +0000
+++ b/bzrlib/tests/test_osutils_encodings.py	2008-05-05 17:02:02 +0000
@@ -197,6 +197,15 @@
                           ' Continuing with ascii encoding.\n',
                           sys.stderr.getvalue())
 
+    def test_user_empty(self):
+        """Running bzr from a vim script gives '' for a preferred locale"""
+        def f():
+            return ''
+
+        locale.getpreferredencoding = f
+        self.assertEquals('ascii', osutils.get_user_encoding(use_cache=False))
+        self.assertEquals('', sys.stderr.getvalue())
+
     def test_user_locale_error(self):
         def f():
             raise locale.Error, 'unsupported locale'




More information about the bazaar-commits mailing list