From d157b6236fb8b3fc3fb51c38f2bcb235b22ccd8c Mon Sep 17 00:00:00 2001 From: Tommy Guy Date: Mon, 20 Apr 2015 16:36:48 -0700 Subject: [PATCH] Switched to stdout codec, and switched ignore to replace. This could be a teaching moment: better to know you don't know. --- tweepy/models.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tweepy/models.py b/tweepy/models.py index 0db677e..af80986 100644 --- a/tweepy/models.py +++ b/tweepy/models.py @@ -77,9 +77,10 @@ class Status(Model): status = cls(api) # I'm not proud. Blame billg. - json['text'] = str(json['text'].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('ascii', 'ignore'))[2:-1] + 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(): -- 2.39.5