[tahoe-dev] [tahoe-lafs] #534: CLI (e.g. tahoe cp) does not correctly handle or display Unicode file/directory names, either in arguments or the local filesystem

tahoe-lafs trac at allmydata.org
Sun Dec 6 19:52:53 PST 2009


#534: CLI (e.g. tahoe cp) does not correctly handle or display Unicode
file/directory names, either in arguments or the local filesystem
-----------------------------------+----------------------------------------
     Reporter:  francois           |       Owner:  francois                                 
         Type:  defect             |      Status:  new                                      
     Priority:  major              |   Milestone:  eventually                               
    Component:  code-frontend-cli  |     Version:  1.2.0                                    
   Resolution:                     |    Keywords:  cp unicode filename forward-compatibility
Launchpad_bug:                     |  
-----------------------------------+----------------------------------------

Comment(by davidsarah):

 Sigh. I misread the exception message in #734. It is complaining about
 {{{sys.stdout.encoding}}} being None when stdout is redirected, not about
 the input string being None. So the fix for that should be something like

 {{{
 def unicode_to_stdout(s):
     """
     Encode an unicode object for representation on stdout.
     """

     precondition(isinstance(s, unicode), s)

     enc = sys.stdout.encoding
     if enc is None or enc == 'cp65001':
         enc = 'utf-8'

     try:
         return s.encode(enc, 'replace')
     catch LookupError:
         return s.encode('utf-8', 'replace')  # maybe
 }}}

 It might also be a good idea to write a BOM at the start of the output.
 That would allow the encoding to be autodetected if a file containing
 redirected output is edited, which is helpful at least on Windows, and
 should be harmless on other platforms.

 At least I did better at scrabble (won by 3 points :-)

-- 
Ticket URL: <http://allmydata.org/trac/tahoe/ticket/534#comment:79>
tahoe-lafs <http://allmydata.org>
secure decentralized file storage grid


More information about the tahoe-dev mailing list