Merge branch 'master' of github.com:guyrt/twitter-data-examples
authorBenjamin Mako Hill <mako@atdot.cc>
Sat, 25 Apr 2015 18:19:36 +0000 (11:19 -0700)
committerBenjamin Mako Hill <mako@atdot.cc>
Sat, 25 Apr 2015 18:19:36 +0000 (11:19 -0700)
tweepy/models.py

index 09ed3eb..af80986 100644 (file)
@@ -77,8 +77,10 @@ class Status(Model):
         status = cls(api)
 
         # I'm not proud. Blame billg.
-        json['text'] = str(json['text'].encode('ascii', 'ignore'))[2:-1]
-        json['user']['screen_name'] = str(json['user']['screen_name'].encode('ascii', 'ignore'))[2:-1]
+        import sys
+        json['text'] = str(json['text'].encode(sys.stdout.encoding, 'replace'))[2:-1]
+        if 'user' in json:
+            json['user']['screen_name'] = str(json['user']['screen_name'].encode(sys.stdout.encoding, 'replace'))[2:-1]
 
         setattr(status, '_json', json)
         for k, v in json.items():

Benjamin Mako Hill || Want to submit a patch?