@@ -183,7 +183,7 @@ def set_parameter(self, parameter, value):
183
183
def get_parameter (self , parameter ):
184
184
try :
185
185
return self .parameters [parameter ]
186
- except :
186
+ except KeyError :
187
187
raise OAuthError ('Parameter not found: %s' % parameter )
188
188
189
189
def _get_timestamp_nonce (self ):
@@ -224,7 +224,7 @@ def get_normalized_parameters(self):
224
224
try :
225
225
# Exclude the signature if it exists.
226
226
del params ['oauth_signature' ]
227
- except :
227
+ except KeyError :
228
228
pass
229
229
# Escape key values before sorting.
230
230
key_values = [(escape (_utf8_str (k )), escape (_utf8_str (v ))) \
@@ -278,7 +278,7 @@ def from_request(http_method, http_url, headers=None, parameters=None,
278
278
# Get the parameters from the header.
279
279
header_params = OAuthRequest ._split_header (auth_header )
280
280
parameters .update (header_params )
281
- except :
281
+ except Exception :
282
282
raise OAuthError ('Unable to parse OAuth parameters from '
283
283
'Authorization header.' )
284
284
@@ -450,7 +450,7 @@ def _get_version(self, oauth_request):
450
450
"""Verify the correct version request for this server."""
451
451
try :
452
452
version = oauth_request .get_parameter ('oauth_version' )
453
- except :
453
+ except Exception :
454
454
version = VERSION
455
455
if version and version != self .version :
456
456
raise OAuthError ('OAuth version %s not supported.' % str (version ))
@@ -461,12 +461,12 @@ def _get_signature_method(self, oauth_request):
461
461
try :
462
462
signature_method = oauth_request .get_parameter (
463
463
'oauth_signature_method' )
464
- except :
464
+ except Exception :
465
465
signature_method = SIGNATURE_METHOD
466
466
try :
467
467
# Get the signature method object.
468
468
signature_method = self .signature_methods [signature_method ]
469
- except :
469
+ except KeyError :
470
470
signature_method_names = ', ' .join (self .signature_methods .keys ())
471
471
raise OAuthError ('Signature method %s not supported try one of the '
472
472
'following: %s' % (signature_method , signature_method_names ))
@@ -498,7 +498,7 @@ def _check_signature(self, oauth_request, consumer, token):
498
498
signature_method = self ._get_signature_method (oauth_request )
499
499
try :
500
500
signature = oauth_request .get_parameter ('oauth_signature' )
501
- except :
501
+ except Exception :
502
502
raise OAuthError ('Missing signature.' )
503
503
# Validate the signature.
504
504
valid_sig = signature_method .check_signature (oauth_request , consumer ,
@@ -629,7 +629,7 @@ def build_signature(self, oauth_request, consumer, token):
629
629
try :
630
630
import hashlib # 2.5
631
631
hashed = hmac .new (key , raw , hashlib .sha1 )
632
- except :
632
+ except ImportError :
633
633
import sha # Deprecated
634
634
hashed = hmac .new (key , raw , sha )
635
635
0 commit comments