~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/annotate.py

  • Committer: Adeodato Simó
  • Date: 2007-07-06 20:25:52 UTC
  • mto: (2593.2.1 ianc-integration)
  • mto: This revision was merged to the branch mainline in revision 2594.
  • Revision ID: dato@net.com.org.es-20070706202552-cecsuokhzhb7sqgn
Add comment from John to the try/except block.

Show diffs side-by-side

added added

removed removed

Lines of Context:
83
83
        try:
84
84
            to_file.write(anno)
85
85
        except UnicodeEncodeError:
 
86
            # cmd_annotate should be passing in an 'exact' object, which means
 
87
            # we have a direct handle to sys.stdout or equivalent. It may not
 
88
            # be able to handle the exact Unicode characters, but 'annotate' is
 
89
            # a user function (non-scripting), so shouldn't die because of
 
90
            # unrepresentable annotation characters. So encode using 'replace',
 
91
            # and write them again.
86
92
            encoding = getattr(to_file, 'encoding', None) or \
87
93
                    osutils.get_terminal_encoding()
88
94
            to_file.write(anno.encode(encoding, 'replace'))