Merge lp:~vila/bzr/1086209-lc-all-c into lp:bzr

Proposed by Vincent Ladeuil
Status: Merged
Approved by: Vincent Ladeuil
Approved revision: no longer in the source branch.
Merged at revision: 6572
Proposed branch: lp:~vila/bzr/1086209-lc-all-c
Merge into: lp:bzr
Diff against target: 47 lines (+10/-5)
3 files modified
bzrlib/tests/test_ui.py (+0/-1)
bzrlib/ui/text.py (+7/-1)
doc/en/release-notes/bzr-2.6.txt (+3/-3)
To merge this branch: bzr merge lp:~vila/bzr/1086209-lc-all-c
Reviewer Review Type Date Requested Status
John A Meinel Approve
Review via email: mp+137862@code.launchpad.net

Commit message

Fix LC_ALL=C test failures related to utf8 stderr encoding

Description of the change

This should fix the LC_ALL=C test failures.

It's a bit weird that we didn't try to use the self.stderr encoding so I
went with a conservative fix: if something bad happens, we'll fall back to
the previous implementation.

To post a comment you must log in.
Revision history for this message
John A Meinel (jameinel) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 2012-12-04 18:29, Vincent Ladeuil wrote:
> Vincent Ladeuil has proposed merging lp:~vila/bzr/1086209-lc-all-c
> into lp:bzr.
>
> Requested reviews: bzr-core (bzr-core) Related bugs: Bug #1086209
> in Bazaar: "test failures in bzr.dev when run with LC_ALL=C"
> https://bugs.launchpad.net/bzr/+bug/1086209
>
> For more details, see:
> https://code.launchpad.net/~vila/bzr/1086209-lc-all-c/+merge/137862
>
> This should fix the LC_ALL=C test failures.
>
> It's a bit weird that we didn't try to use the self.stderr encoding
> so I went with a conservative fix: if something bad happens, we'll
> fall back to the previous implementation.
>

+* Fix test failures occurring only with LC_ALL=C, when prompting a user,
+ ``stdee`` encoding should be preferred over terminal encoding if
+ available. (Vincent Ladeuil, #1086209)

tyop

Otherwise:
 review: approve

John
=:->

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (Cygwin)
Comment: Using GnuPG with undefined - http://www.enigmail.net/

iEYEARECAAYFAlC+HCMACgkQJdeBCYSNAAP4dACfd6iuMu3YbSn+ICQMQKKZqs2L
JZUAn0iYiaxAE1q0Z0r4W1dAVkHwODx+
=lqmC
-----END PGP SIGNATURE-----

review: Approve
Revision history for this message
Vincent Ladeuil (vila) wrote :

sent to pqm by email

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/tests/test_ui.py'
2--- bzrlib/tests/test_ui.py 2012-09-17 09:06:56 +0000
3+++ bzrlib/tests/test_ui.py 2012-12-04 16:40:37 +0000
4@@ -103,7 +103,6 @@
5 ui.stdout = tests.StringIOWrapper()
6 ui.stderr = tests.StringIOWrapper()
7 ui.stderr.encoding = ui.stdout.encoding = ui.stdin.encoding = 'utf8'
8- pb = ui.nested_progress_bar()
9 password = ui.get_password(u'Hello \u1234 %(user)s', user=u'some\u1234')
10 self.assertEqual(u'baz\u1234', password)
11 self.assertEqual(u'Hello \u1234 some\u1234: ',
12
13=== modified file 'bzrlib/ui/text.py'
14--- bzrlib/ui/text.py 2012-10-10 18:45:21 +0000
15+++ bzrlib/ui/text.py 2012-12-04 16:40:37 +0000
16@@ -336,7 +336,13 @@
17 if kwargs:
18 # See <https://launchpad.net/bugs/365891>
19 prompt = prompt % kwargs
20- prompt = prompt.encode(osutils.get_terminal_encoding(), 'replace')
21+ try:
22+ prompt = prompt.encode(self.stderr.encoding)
23+ except (UnicodeError, AttributeError):
24+ # If stderr has no encoding attribute or can't properly encode,
25+ # fallback to terminal encoding for robustness (better display
26+ # something to the user than aborting with a traceback).
27+ prompt = prompt.encode(osutils.get_terminal_encoding(), 'replace')
28 self.clear_term()
29 self.stdout.flush()
30 self.stderr.write(prompt)
31
32=== modified file 'doc/en/release-notes/bzr-2.6.txt'
33--- doc/en/release-notes/bzr-2.6.txt 2012-10-23 10:22:25 +0000
34+++ doc/en/release-notes/bzr-2.6.txt 2012-12-04 16:40:37 +0000
35@@ -104,9 +104,9 @@
36 Testing
37 *******
38
39-.. Fixes and changes that are only relevant to bzr's test framework and
40- suite. This can include new facilities for writing tests, fixes to
41- spurious test failures and changes to the way things should be tested.
42+* Fix test failures occurring only with LC_ALL=C, when prompting a user,
43+ ``stderr`` encoding should be preferred over terminal encoding if
44+ available. (Vincent Ladeuil, #1086209)
45
46
47 bzr 2.6b2