From dc68896016e02a249a24f2204b571592cbc46de2 Mon Sep 17 00:00:00 2001 From: Taylor Jung Date: Sat, 12 May 2018 20:09:30 +0900 Subject: [PATCH] Fix Python3.7 compatibility issue passing "async" argument can make invalid argument error on python 3.7 --- tweepy/streaming.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tweepy/streaming.py b/tweepy/streaming.py index 43aa823..d6f0f80 100644 --- a/tweepy/streaming.py +++ b/tweepy/streaming.py @@ -355,9 +355,9 @@ class Stream(object): if resp.raw.closed: self.on_closed(resp) - def _start(self, async): + def _start(self, is_async): self.running = True - if async: + if is_async: self._thread = Thread(target=self._run) self._thread.start() else: @@ -373,7 +373,7 @@ class Stream(object): replies=None, track=None, locations=None, - async=False, + is_async=False, encoding='utf8'): self.session.params = {'delimited': 'length'} if self.running: @@ -394,25 +394,25 @@ class Stream(object): if track: self.session.params['track'] = u','.join(track).encode(encoding) - self._start(async) + self._start(is_async) - def firehose(self, count=None, async=False): + def firehose(self, count=None, is_async=False): self.session.params = {'delimited': 'length'} if self.running: raise TweepError('Stream object already connected!') self.url = '/%s/statuses/firehose.json' % STREAM_VERSION if count: self.url += '&count=%s' % count - self._start(async) + self._start(is_async) - def retweet(self, async=False): + def retweet(self, is_async=False): self.session.params = {'delimited': 'length'} if self.running: raise TweepError('Stream object already connected!') self.url = '/%s/statuses/retweet.json' % STREAM_VERSION - self._start(async) + self._start(is_async) - def sample(self, async=False, languages=None, stall_warnings=False): + def sample(self, is_async=False, languages=None, stall_warnings=False): self.session.params = {'delimited': 'length'} if self.running: raise TweepError('Stream object already connected!') @@ -421,9 +421,9 @@ class Stream(object): self.session.params['language'] = ','.join(map(str, languages)) if stall_warnings: self.session.params['stall_warnings'] = 'true' - self._start(async) + self._start(is_async) - def filter(self, follow=None, track=None, async=False, locations=None, + def filter(self, follow=None, track=None, is_async=False, locations=None, stall_warnings=False, languages=None, encoding='utf8', filter_level=None): self.body = {} self.session.headers['Content-type'] = "application/x-www-form-urlencoded" @@ -447,10 +447,10 @@ class Stream(object): self.body['filter_level'] = filter_level.encode(encoding) self.session.params = {'delimited': 'length'} self.host = 'stream.twitter.com' - self._start(async) + self._start(is_async) def sitestream(self, follow, stall_warnings=False, - with_='user', replies=False, async=False): + with_='user', replies=False, is_async=False): self.body = {} if self.running: raise TweepError('Stream object already connected!') @@ -463,7 +463,7 @@ class Stream(object): self.body['with'] = with_ if replies: self.body['replies'] = replies - self._start(async) + self._start(is_async) def disconnect(self): if self.running is False: -- 2.25.1