Properly encode messages sent to stderr (fixes issue #34)
authorRicardo Garcia <sarbalap+freshmeat@gmail.com>
Mon, 13 Jul 2009 13:25:14 +0000 (15:25 +0200)
committerRicardo Garcia <sarbalap+freshmeat@gmail.com>
Sun, 31 Oct 2010 10:24:43 +0000 (11:24 +0100)
youtube-dl

index 0fd160c2a9762759940a9c3aee06830510372332..36b6331cb09c90e2f0736e6e76536675eb248707 100755 (executable)
@@ -227,7 +227,7 @@ class FileDownloader(object):
        
        def to_stderr(self, message):
                """Print message to stderr."""
-               print >>sys.stderr, message
+               print >>sys.stderr, message.encode(locale.getpreferredencoding())
        
        def fixed_template(self):
                """Checks if the output template is fixed."""
@@ -308,7 +308,7 @@ class FileDownloader(object):
                except (ValueError, KeyError), err:
                        self.trouble('ERROR: invalid output template or system charset: %s' % str(err))
                if self.params['nooverwrites'] and os.path.exists(filename):
-                       self.to_stderr('WARNING: file exists: %s; skipping' % filename)
+                       self.to_stderr(u'WARNING: file exists: %s; skipping' % filename)
                        return
 
                try: