Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Zahra Rajabi
tweepy
Commits
5bb8c4c6
Commit
5bb8c4c6
authored
Feb 20, 2014
by
Aaron Hill
Browse files
Use new exception-related syntax for Python 3 compatibility
parent
93b64620
Changes
6
Hide whitespace changes
Inline
Side-by-side
tweepy/api.py
View file @
5bb8c4c6
...
...
@@ -329,7 +329,7 @@ class API(object):
require_auth
=
True
,
allowed_param
=
[
'include_entities'
,
'skip_status'
],
)(
self
,
**
kargs
)
except
TweepError
,
e
:
except
TweepError
as
e
:
if
e
.
response
and
e
.
response
.
status
==
401
:
return
False
raise
...
...
tweepy/auth.py
View file @
5bb8c4c6
...
...
@@ -67,7 +67,7 @@ class OAuthHandler(AuthHandler):
request
.
sign_request
(
self
.
_sigmethod
,
self
.
_consumer
,
None
)
resp
=
urlopen
(
Request
(
url
,
headers
=
request
.
to_header
()))
return
oauth
.
OAuthToken
.
from_string
(
resp
.
read
())
except
Exception
,
e
:
except
Exception
as
e
:
raise
TweepError
(
e
)
def
set_request_token
(
self
,
key
,
secret
):
...
...
@@ -92,7 +92,7 @@ class OAuthHandler(AuthHandler):
)
return
request
.
to_url
()
except
Exception
,
e
:
except
Exception
as
e
:
raise
TweepError
(
e
)
def
get_access_token
(
self
,
verifier
=
None
):
...
...
@@ -115,7 +115,7 @@ class OAuthHandler(AuthHandler):
resp
=
urlopen
(
Request
(
url
,
headers
=
request
.
to_header
()))
self
.
access_token
=
oauth
.
OAuthToken
.
from_string
(
resp
.
read
())
return
self
.
access_token
except
Exception
,
e
:
except
Exception
as
e
:
raise
TweepError
(
e
)
def
get_xauth_access_token
(
self
,
username
,
password
):
...
...
@@ -141,7 +141,7 @@ class OAuthHandler(AuthHandler):
resp
=
urlopen
(
Request
(
url
,
data
=
request
.
to_postdata
()))
self
.
access_token
=
oauth
.
OAuthToken
.
from_string
(
resp
.
read
())
return
self
.
access_token
except
Exception
,
e
:
except
Exception
as
e
:
raise
TweepError
(
e
)
def
get_username
(
self
):
...
...
tweepy/binder.py
View file @
5bb8c4c6
...
...
@@ -153,7 +153,7 @@ def bind_api(**config):
try
:
conn
.
request
(
self
.
method
,
url
,
headers
=
self
.
headers
,
body
=
self
.
post_data
)
resp
=
conn
.
getresponse
()
except
Exception
,
e
:
except
Exception
as
e
:
raise
TweepError
(
'Failed to send request: %s'
%
e
)
# Exit request loop if non-retry error code
...
...
@@ -181,7 +181,7 @@ def bind_api(**config):
try
:
zipper
=
gzip
.
GzipFile
(
fileobj
=
StringIO
(
body
))
body
=
zipper
.
read
()
except
Exception
,
e
:
except
Exception
as
e
:
raise
TweepError
(
'Failed to decompress data: %s'
%
e
)
result
=
self
.
api
.
parser
.
parse
(
self
,
body
)
...
...
tweepy/parsers.py
View file @
5bb8c4c6
...
...
@@ -48,7 +48,7 @@ class JSONParser(Parser):
def
parse
(
self
,
method
,
payload
):
try
:
json
=
self
.
json_lib
.
loads
(
payload
)
except
Exception
,
e
:
except
Exception
as
e
:
raise
TweepError
(
'Failed to parse JSON payload: %s'
%
e
)
needsCursors
=
method
.
parameters
.
has_key
(
'cursor'
)
...
...
tweepy/streaming.py
View file @
5bb8c4c6
...
...
@@ -171,7 +171,7 @@ class Stream(object):
self
.
snooze_time
=
self
.
snooze_time_step
self
.
listener
.
on_connect
()
self
.
_read_loop
(
resp
)
except
(
timeout
,
ssl
.
SSLError
)
,
exc
:
except
(
timeout
,
ssl
.
SSLError
)
as
exc
:
# If it's not time out treat it like any other exception
if
isinstance
(
exc
,
ssl
.
SSLError
)
and
not
(
exc
.
args
and
'timed out'
in
str
(
exc
.
args
[
0
])):
exception
=
exc
...
...
@@ -185,7 +185,7 @@ class Stream(object):
sleep
(
self
.
snooze_time
)
self
.
snooze_time
=
min
(
self
.
snooze_time
+
self
.
snooze_time_step
,
self
.
snooze_time_cap
)
except
Exception
,
exception
:
except
Exception
as
exception
:
# any other exception is fatal, so kill loop
break
...
...
tweepy/utils.py
View file @
5bb8c4c6
...
...
@@ -47,7 +47,7 @@ def import_simplejson():
try
:
from
django.utils
import
simplejson
as
json
# Google App Engine
except
ImportError
:
raise
ImportError
,
"Can't load a json library"
raise
ImportError
(
"Can't load a json library"
)
return
json
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment