Permalink
Browse files

Backed out syntax changes specific to 2.5.

  • Loading branch information...
1 parent 475532d commit e916390ce0ac464e4d1356a7c33edc9c55c7cb7f @mmerickel mmerickel committed Sep 23, 2011
@@ -3,7 +3,6 @@
from hashlib import md5
import datetime
import re
-import sys
import time as time_mod
import urllib
@@ -472,8 +471,7 @@ def parse_ticket(secret, ticket, ip):
digest = ticket[:32]
try:
timestamp = int(ticket[32:40], 16)
- except ValueError:
- e = sys.exc_info()[1]
+ except ValueError as e:
raise BadTicket('Timestamp is not a hex integer: %s' % e)
try:
userid, data = ticket[40:].split('!', 1)
View
@@ -1,5 +1,4 @@
import re
-import sys
import traceback
from pyramid.exceptions import ConfigurationError
@@ -112,8 +111,7 @@ def request_method_predicate(context, request):
if path_info is not None:
try:
path_info_val = re.compile(path_info)
- except re.error:
- why = sys.exc_info()[1]
+ except re.error as why:
raise ConfigurationError(why[0])
def path_info_predicate(context, request):
return path_info_val.match(request.path_info) is not None
@@ -147,8 +145,7 @@ def request_param_predicate(context, request):
header_name, header_val = header.split(':', 1)
try:
header_val = re.compile(header_val)
- except re.error:
- why = sys.exc_info()[1]
+ except re.error as why:
raise ConfigurationError(why[0])
if header_val is None:
text = "header %s" % header_name
View
@@ -2,7 +2,6 @@
import base64
import binascii
import hmac
-import sys
import time
import os
@@ -254,9 +253,8 @@ def signed_deserialize(serialized, secret, hmac=hmac):
try:
input_sig, pickled = (serialized[:40],
base64.standard_b64decode(serialized[40:]))
- except (binascii.Error, TypeError):
+ except (binascii.Error, TypeError) as e:
# Badly formed data can make base64 die
- e = sys.exc_info()[1]
raise ValueError('Badly formed base64 data: %s' % e)
sig = hmac.new(secret, pickled, sha1).hexdigest()
@@ -1,5 +1,4 @@
import unittest
-import sys
from pyramid import testing
from pyramid.tests.test_config import IDummy
@@ -2531,8 +2530,7 @@ def test_secured_view_raises_forbidden_no_name(self):
request.url = 'url'
try:
result(None, request)
- except HTTPForbidden:
- e = sys.exc_info()[1]
+ except HTTPForbidden as e:
self.assertEqual(e.message,
'Unauthorized: <lambda> failed permission check')
else: # pragma: no cover
@@ -2554,8 +2552,7 @@ def myview(request): pass
request.url = 'url'
try:
result(None, request)
- except HTTPForbidden:
- e = sys.exc_info()[1]
+ except HTTPForbidden as e:
self.assertEqual(e.message,
'Unauthorized: myview failed permission check')
else: # pragma: no cover
@@ -2573,8 +2570,7 @@ def predicate1(context, request):
request.method = 'POST'
try:
result(None, None)
- except PredicateMismatch:
- e = sys.exc_info()[1]
+ except PredicateMismatch as e:
self.assertEqual(e.detail, 'predicate mismatch for view <lambda>')
else: # pragma: no cover
raise AssertionError
@@ -2590,8 +2586,7 @@ def predicate1(context, request):
request.method = 'POST'
try:
result(None, None)
- except PredicateMismatch:
- e = sys.exc_info()[1]
+ except PredicateMismatch as e:
self.assertEqual(e.detail, 'predicate mismatch for view myview')
else: # pragma: no cover
raise AssertionError
@@ -1,4 +1,3 @@
-import sys
import unittest
from pyramid import testing
@@ -1205,8 +1204,7 @@ def info(self, msg):
def exc_raised(exc, func, *arg, **kw):
try:
func(*arg, **kw)
- except exc:
- e = sys.exc_info()[1]
+ except exc as e:
return e
else:
raise AssertionError('%s not raised' % exc) # pragma: no cover
@@ -1,5 +1,4 @@
import unittest
-import sys
class TestDottedNameResolver(unittest.TestCase):
def _makeOne(self, package=None):
@@ -10,8 +9,7 @@ def config_exc(self, func, *arg, **kw):
from pyramid.exceptions import ConfigurationError
try:
func(*arg, **kw)
- except ConfigurationError:
- e = sys.exc_info()[1]
+ except ConfigurationError as e:
return e
else:
raise AssertionError('Invalid not raised') # pragma: no cover
View
@@ -1,4 +1,3 @@
-import sys
import urllib
import warnings
@@ -484,8 +483,7 @@ def traversal_path(path):
segment = urllib.unquote(segment)
try:
segment = segment.decode('utf-8')
- except UnicodeDecodeError:
- e = sys.exc_info()[1]
+ except UnicodeDecodeError as e:
raise URLDecodeError(e.encoding, e.object, e.start, e.end, e.reason)
if not segment or segment == '.':
continue
View
@@ -1,5 +1,4 @@
import re
-import sys
from zope.interface import implementer
from pyramid.interfaces import IRoutesMapper
@@ -141,8 +140,7 @@ def matcher(path):
encoded = url_unquote(v)
try:
d[k] = encoded.decode('utf-8')
- except UnicodeDecodeError:
- e = sys.exc_info()[1]
+ except UnicodeDecodeError as e:
raise URLDecodeError(
e.encoding, e.object, e.start, e.end, e.reason
)

0 comments on commit e916390

Please sign in to comment.