~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/ui/text.py

  • Committer: Patch Queue Manager
  • Date: 2012-12-10 10:18:33 UTC
  • mfrom: (6571.1.2 1086209-lc-all-c)
  • Revision ID: pqm@pqm.ubuntu.com-20121210101833-06scfp3a4w0x0z87
(vila) Fix LC_ALL=C test failures related to utf8 stderr encoding (Vincent
 Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
336
336
        if kwargs:
337
337
            # See <https://launchpad.net/bugs/365891>
338
338
            prompt = prompt % kwargs
339
 
        prompt = prompt.encode(osutils.get_terminal_encoding(), 'replace')
 
339
        try:
 
340
            prompt = prompt.encode(self.stderr.encoding)
 
341
        except (UnicodeError, AttributeError):
 
342
            # If stderr has no encoding attribute or can't properly encode,
 
343
            # fallback to terminal encoding for robustness (better display
 
344
            # something to the user than aborting with a traceback).
 
345
            prompt = prompt.encode(osutils.get_terminal_encoding(), 'replace')
340
346
        self.clear_term()
341
347
        self.stdout.flush()
342
348
        self.stderr.write(prompt)