~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/ui/text.py

  • Committer: Vincent Ladeuil
  • Date: 2012-12-04 14:21:42 UTC
  • mto: This revision was merged to the branch mainline in revision 6572.
  • Revision ID: v.ladeuil+lp@free.fr-20121204142142-mx8v8k2o5k3yi1ex
Fix LC_ALL=C test failures related to utf8 stderr encoding

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)