Raise error if locations list has the wrong length
authormarianitadn <maria.nita.dn@gmail.com>
Wed, 16 Apr 2014 11:48:01 +0000 (14:48 +0300)
committermarianitadn <maria.nita.dn@gmail.com>
Sat, 19 Apr 2014 09:40:12 +0000 (12:40 +0300)
tweepy/streaming.py

index 7a8cf0db3f3ce2b423fda0a80e6def888e1e2548..694f96671705a63256e51aa4daeb6eb64ba968c9 100644 (file)
@@ -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