Rev 2986: Output to stderr with trace module now going through wrapper that in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Tue Nov 13 22:27:00 GMT 2007


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

------------------------------------------------------------
revno: 2986
revision-id: pqm at pqm.ubuntu.com-20071113222657-2x5wq0rwwrb7rv2y
parent: pqm at pqm.ubuntu.com-20071113213549-jdbrso1a6zbaufx7
parent: bialix at ukr.net-20071113203341-c8v4umxfqkdd4gu7
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2007-11-13 22:26:57 +0000
message:
  Output to stderr with trace module now going through wrapper that
   takes care about terminal encoding. (#54173)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/trace.py                trace.py-20050309040759-c8ed824bdcd4748a
    ------------------------------------------------------------
    revno: 2978.1.2
    merged: bialix at ukr.net-20071113203341-c8v4umxfqkdd4gu7
    parent: bialix at ukr.net-20071110170940-tmidd24tpaxn7r2l
    parent: pqm at pqm.ubuntu.com-20071113183931-av8ih92ad65slodl
    committer: Alexander Belchenko <bialix at ukr.net>
    branch nick: stderr.non.utf8
    timestamp: Tue 2007-11-13 22:33:41 +0200
    message:
      merge bzr.dev
    ------------------------------------------------------------
    revno: 2978.1.1
    merged: bialix at ukr.net-20071110170940-tmidd24tpaxn7r2l
    parent: pqm at pqm.ubuntu.com-20071109195036-5o5bwu0a01uniqwg
    committer: Alexander Belchenko <bialix at ukr.net>
    branch nick: stderr.non.utf8
    timestamp: Sat 2007-11-10 19:09:40 +0200
    message:
      Output to stderr with trace module now going through wrapper that takes care about terminal encoding. (#54173)
=== modified file 'NEWS'
--- a/NEWS	2007-11-13 20:49:38 +0000
+++ b/NEWS	2007-11-13 22:26:57 +0000
@@ -66,6 +66,11 @@
 
    * Reconcile now shows progress bars. (Robert Collins, #159351)
 
+   * Stderr output via logging mechanism now goes through encoded wrapper
+     and no more uses utf-8, but terminal encoding instead. So all unicode
+     strings now should be readable in non-utf-8 terminal.
+     (Alexander Belchenko, #54173)
+
    * The error message when ``move --after`` should be used makes how to do so
      clearer. (Daniel Watkins, #85237)
 

=== modified file 'bzrlib/trace.py'
--- a/bzrlib/trace.py	2007-10-16 17:37:43 +0000
+++ b/bzrlib/trace.py	2007-11-10 17:09:40 +0000
@@ -50,6 +50,8 @@
 # is quite expensive, even when the message is not printed by any handlers.
 # We should perhaps change back to just simply doing it here.
 
+import codecs
+import logging
 import os
 import sys
 import re
@@ -59,7 +61,6 @@
 from cStringIO import StringIO
 import errno
 import locale
-import logging
 import traceback
 """)
 
@@ -87,6 +88,7 @@
 
 _bzr_logger = logging.getLogger('bzr')
 
+
 def note(*args, **kwargs):
     # FIXME note always emits utf-8, regardless of the terminal encoding
     import bzrlib.ui
@@ -212,7 +214,10 @@
     """Configure default logging to stderr and .bzr.log"""
     # FIXME: if this is run twice, things get confused
     global _stderr_handler, _file_handler, _trace_file, _bzr_log_file
-    _stderr_handler = logging.StreamHandler()
+    # create encoded wrapper around stderr
+    stderr = codecs.getwriter(osutils.get_terminal_encoding())(sys.stderr,
+        errors='replace')
+    _stderr_handler = logging.StreamHandler(stderr)
     logging.getLogger('').addHandler(_stderr_handler)
     _stderr_handler.setLevel(logging.INFO)
     if not _file_handler:




More information about the bazaar-commits mailing list