Rev 6572: (vila) Fix LC_ALL=C test failures related to utf8 stderr encoding (Vincent in file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
Patch Queue Manager
pqm at pqm.ubuntu.com
Mon Dec 10 10:18:34 UTC 2012
At file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 6572 [merge]
revision-id: pqm at pqm.ubuntu.com-20121210101833-06scfp3a4w0x0z87
parent: pqm at pqm.ubuntu.com-20121025111327-p0ylql0nh9fla0rs
parent: v.ladeuil+lp at free.fr-20121204163655-7r5ygtg628ndy4jp
committer: Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Mon 2012-12-10 10:18:33 +0000
message:
(vila) Fix LC_ALL=C test failures related to utf8 stderr encoding (Vincent
Ladeuil)
modified:
bzrlib/tests/test_ui.py test_ui.py-20051130162854-458e667a7414af09
bzrlib/ui/text.py text.py-20051130153916-2e438cffc8afc478
doc/en/release-notes/bzr-2.6.txt bzr2.6.txt-20120116134316-8w1xxom1c7vcu1t5-1
=== modified file 'bzrlib/tests/test_ui.py'
--- a/bzrlib/tests/test_ui.py 2012-09-17 09:06:56 +0000
+++ b/bzrlib/tests/test_ui.py 2012-12-04 14:21:42 +0000
@@ -103,7 +103,6 @@
ui.stdout = tests.StringIOWrapper()
ui.stderr = tests.StringIOWrapper()
ui.stderr.encoding = ui.stdout.encoding = ui.stdin.encoding = 'utf8'
- pb = ui.nested_progress_bar()
password = ui.get_password(u'Hello \u1234 %(user)s', user=u'some\u1234')
self.assertEqual(u'baz\u1234', password)
self.assertEqual(u'Hello \u1234 some\u1234: ',
=== modified file 'bzrlib/ui/text.py'
--- a/bzrlib/ui/text.py 2012-10-10 18:45:21 +0000
+++ b/bzrlib/ui/text.py 2012-12-04 14:21:42 +0000
@@ -336,7 +336,13 @@
if kwargs:
# See <https://launchpad.net/bugs/365891>
prompt = prompt % kwargs
- prompt = prompt.encode(osutils.get_terminal_encoding(), 'replace')
+ try:
+ prompt = prompt.encode(self.stderr.encoding)
+ except (UnicodeError, AttributeError):
+ # If stderr has no encoding attribute or can't properly encode,
+ # fallback to terminal encoding for robustness (better display
+ # something to the user than aborting with a traceback).
+ prompt = prompt.encode(osutils.get_terminal_encoding(), 'replace')
self.clear_term()
self.stdout.flush()
self.stderr.write(prompt)
=== modified file 'doc/en/release-notes/bzr-2.6.txt'
--- a/doc/en/release-notes/bzr-2.6.txt 2012-10-23 10:22:25 +0000
+++ b/doc/en/release-notes/bzr-2.6.txt 2012-12-04 16:36:55 +0000
@@ -104,9 +104,9 @@
Testing
*******
-.. Fixes and changes that are only relevant to bzr's test framework and
- suite. This can include new facilities for writing tests, fixes to
- spurious test failures and changes to the way things should be tested.
+* Fix test failures occurring only with LC_ALL=C, when prompting a user,
+ ``stderr`` encoding should be preferred over terminal encoding if
+ available. (Vincent Ladeuil, #1086209)
bzr 2.6b2
More information about the bazaar-commits
mailing list