From e2d401b5baacf95d4911e08b742fca52623560a0 Mon Sep 17 00:00:00 2001 From: marianitadn Date: Wed, 16 Apr 2014 14:48:01 +0300 Subject: [PATCH] Raise error if locations list has the wrong length --- tweepy/streaming.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tweepy/streaming.py b/tweepy/streaming.py index 7a8cf0d..694f966 100644 --- a/tweepy/streaming.py +++ b/tweepy/streaming.py @@ -254,7 +254,9 @@ class Stream(object): if replies: self.parameters['replies'] = replies if locations and len(locations) > 0: - assert len(locations) % 4 == 0 + if len(locations) % 4 != 0: + raise TweepError("Wrong number of locations points, " + "it has to be a multiple of 4") self.parameters['locations'] = ','.join(['%.2f' % l for l in locations]) if track: encoded_track = [s.encode(encoding) for s in track] @@ -301,7 +303,9 @@ class Stream(object): encoded_track = [s.encode(encoding) for s in track] self.parameters['track'] = ','.join(encoded_track) if locations and len(locations) > 0: - assert len(locations) % 4 == 0 + if len(locations) % 4 != 0: + raise TweepError("Wrong number of locations points, " + "it has to be a multiple of 4") self.parameters['locations'] = ','.join(['%.4f' % l for l in locations]) if stall_warnings: self.parameters['stall_warnings'] = stall_warnings -- 2.25.1