[csw-devel] SF.net SVN: opencsw:[588] twitter/sweets/sweets.py

skayser at users.sourceforge.net skayser at users.sourceforge.net
Tue Nov 15 22:38:31 CET 2011


Revision: 588
          http://opencsw.svn.sourceforge.net/opencsw/?rev=588&view=rev
Author:   skayser
Date:     2011-11-15 21:38:31 +0000 (Tue, 15 Nov 2011)
Log Message:
-----------
twitter/sweets: also encode output when stdout is redirected, default to utf-8

Modified Paths:
--------------
    twitter/sweets/sweets.py

Modified: twitter/sweets/sweets.py
===================================================================
--- twitter/sweets/sweets.py	2011-11-10 00:51:00 UTC (rev 587)
+++ twitter/sweets/sweets.py	2011-11-15 21:38:31 UTC (rev 588)
@@ -116,8 +116,8 @@
                 tweet['from_user'],
                 tweet['id_str']
             )
-            if os.isatty(1): msg = msg.encode(sys.stdout.encoding, 'replace')
-            print msg
+            encoding = sys.stdout.encoding or 'utf-8'
+            print msg.encode(encoding, 'replace')
 
 
 def twitter_search_mock(query="", state=""):

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the devel mailing list