From 8d719f3f72d60fff406409d5824e6cab6d6965ca Mon Sep 17 00:00:00 2001 From: Phil Gyford Date: Thu, 28 Apr 2016 08:59:52 +0100 Subject: [PATCH] Make html_for_tweet() cope if a tweet has no entities. I'm not 100% sure if it's possible any more to get tweet data that doesn't include entities. I've a feeling it might be, but can't find an example. However, `html_for_tweet()` currently almost handles a tweet not having entities, except it throws `UnboundLocalError` because the `text` variable is declared in the wrong place. This fixes that. --- twython/api.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/twython/api.py b/twython/api.py index 2ed50bc..033357f 100644 --- a/twython/api.py +++ b/twython/api.py @@ -544,8 +544,9 @@ class Twython(EndpointsMixin, object): if 'retweeted_status' in tweet: tweet = tweet['retweeted_status'] + text = tweet['text'] + if 'entities' in tweet: - text = tweet['text'] entities = tweet['entities'] # Mentions