running lib2to3.fixes.fix_except
This commit is contained in:
+4
-4
@@ -58,7 +58,7 @@ def app_pack(app, request, raise_ex=False, filenames=None):
|
||||
filename = apath('../deposit/web2py.app.%s.w2p' % app, request)
|
||||
w2p_pack(filename, apath(app, request), filenames=filenames)
|
||||
return filename
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
import traceback
|
||||
print traceback.format_exc()
|
||||
if raise_ex:
|
||||
@@ -82,7 +82,7 @@ def app_pack_compiled(app, request, raise_ex=False):
|
||||
filename = apath('../deposit/%s.w2p' % app, request)
|
||||
w2p_pack(filename, apath(app, request), compiled=True)
|
||||
return filename
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
if raise_ex:
|
||||
raise
|
||||
return None
|
||||
@@ -423,12 +423,12 @@ def upgrade(request, url='http://web2py.com'):
|
||||
filename = abspath('web2py_%s_downloaded.zip' % version_type)
|
||||
try:
|
||||
write_file(filename, urllib.urlopen(full_url).read(), 'wb')
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
return False, e
|
||||
try:
|
||||
unzip(filename, destination, subfolder)
|
||||
return True, None
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
return False, e
|
||||
|
||||
|
||||
|
||||
+3
-3
@@ -265,7 +265,7 @@ class CacheInRam(CacheAbstract):
|
||||
if key in self.storage:
|
||||
value = self.storage[key][1] + value
|
||||
self.storage[key] = (time.time(), value)
|
||||
except BaseException, e:
|
||||
except BaseException as e:
|
||||
self.locker.release()
|
||||
raise e
|
||||
self.locker.release()
|
||||
@@ -635,7 +635,7 @@ class Cache(object):
|
||||
# action returns something
|
||||
rtn = cache_model(cache_key, lambda: func(), time_expire=time_expire)
|
||||
http, status = None, current.response.status
|
||||
except HTTP, e:
|
||||
except HTTP as e:
|
||||
# action raises HTTP (can still be valid)
|
||||
rtn = cache_model(cache_key, lambda: e.body, time_expire=time_expire)
|
||||
http, status = HTTP(e.status, rtn, **e.headers), e.status
|
||||
@@ -648,7 +648,7 @@ class Cache(object):
|
||||
# action returns something
|
||||
rtn = func()
|
||||
http, status = None, current.response.status
|
||||
except HTTP, e:
|
||||
except HTTP as e:
|
||||
# action raises HTTP (can still be valid)
|
||||
status = e.status
|
||||
http = HTTP(e.status, e.body, **e.headers)
|
||||
|
||||
+1
-1
@@ -475,7 +475,7 @@ def compile_views(folder, skip_failed_views=False):
|
||||
for fname in listdir(path, '^[\w/\-]+(\.\w+)*$'):
|
||||
try:
|
||||
data = parse_template(fname, path)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
if skip_failed_views:
|
||||
failed_views.append(fname)
|
||||
else:
|
||||
|
||||
@@ -259,7 +259,7 @@ def test():
|
||||
print 'Your credit card was declined by your bank'
|
||||
elif payment.isError():
|
||||
raise AIM.AIMError('An uncaught error occurred')
|
||||
except AIM.AIMError, e:
|
||||
except AIM.AIMError as e:
|
||||
print "Exception thrown:", e
|
||||
print 'An error occured'
|
||||
print 'approved', payment.isApproved()
|
||||
|
||||
@@ -233,7 +233,7 @@ def test():
|
||||
print 'Your credit card was declined by your bank'
|
||||
elif payment.isError():
|
||||
raise DowCommerce.DowCommerceError('An uncaught error occurred')
|
||||
except DowCommerce.DowCommerceError, e:
|
||||
except DowCommerce.DowCommerceError as e:
|
||||
print "Exception thrown:", e
|
||||
print 'An error occured'
|
||||
print 'approved', payment.isApproved()
|
||||
|
||||
@@ -69,7 +69,7 @@ def autoretry_datastore_timeouts(attempts=5.0, interval=0.1, exponent=2.0):
|
||||
while True:
|
||||
try:
|
||||
return wrapped(*args, **kwargs)
|
||||
except apiproxy_errors.ApplicationError, err:
|
||||
except apiproxy_errors.ApplicationError as err:
|
||||
errno = err.application_error
|
||||
if errno not in errors:
|
||||
raise
|
||||
|
||||
@@ -470,7 +470,7 @@ class Record(object):
|
||||
while length:
|
||||
try:
|
||||
data = sock.recv(length)
|
||||
except socket.error, e:
|
||||
except socket.error as e:
|
||||
if e[0] == errno.EAGAIN:
|
||||
select.select([sock], [], [])
|
||||
continue
|
||||
@@ -527,7 +527,7 @@ class Record(object):
|
||||
while length:
|
||||
try:
|
||||
sent = sock.send(data)
|
||||
except socket.error, e:
|
||||
except socket.error as e:
|
||||
if e[0] == errno.EAGAIN:
|
||||
select.select([], [sock], [])
|
||||
continue
|
||||
@@ -664,7 +664,7 @@ class Connection(object):
|
||||
self.process_input()
|
||||
except EOFError:
|
||||
break
|
||||
except (select.error, socket.error), e:
|
||||
except (select.error, socket.error) as e:
|
||||
if e[0] == errno.EBADF: # Socket was closed by Request.
|
||||
break
|
||||
raise
|
||||
@@ -990,7 +990,7 @@ class Server(object):
|
||||
socket.SOCK_STREAM)
|
||||
try:
|
||||
sock.getpeername()
|
||||
except socket.error, e:
|
||||
except socket.error as e:
|
||||
if e[0] == errno.ENOTSOCK:
|
||||
# Not a socket, assume CGI context.
|
||||
isFCGI = False
|
||||
@@ -1077,7 +1077,7 @@ class Server(object):
|
||||
while self._keepGoing:
|
||||
try:
|
||||
r, w, e = select.select([sock], [], [], timeout)
|
||||
except select.error, e:
|
||||
except select.error as e:
|
||||
if e[0] == errno.EINTR:
|
||||
continue
|
||||
raise
|
||||
@@ -1085,7 +1085,7 @@ class Server(object):
|
||||
if r:
|
||||
try:
|
||||
clientSock, addr = sock.accept()
|
||||
except socket.error, e:
|
||||
except socket.error as e:
|
||||
if e[0] in (errno.EINTR, errno.EAGAIN):
|
||||
continue
|
||||
raise
|
||||
@@ -1273,7 +1273,7 @@ class WSGIServer(Server):
|
||||
finally:
|
||||
if hasattr(result, 'close'):
|
||||
result.close()
|
||||
except socket.error, e:
|
||||
except socket.error as e:
|
||||
if e[0] != errno.EPIPE:
|
||||
raise # Don't let EPIPE propagate beyond server
|
||||
finally:
|
||||
|
||||
@@ -14,11 +14,11 @@ def wrapper(f):
|
||||
try:
|
||||
output = f(data)
|
||||
return XML(ouput)
|
||||
except (TypeError, ValueError), e:
|
||||
except (TypeError, ValueError) as e:
|
||||
raise HTTP(405, '%s serialization error' % e)
|
||||
except ImportError, e:
|
||||
except ImportError as e:
|
||||
raise HTTP(405, '%s not available' % e)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
raise HTTP(405, '%s error' % e)
|
||||
return g
|
||||
|
||||
|
||||
@@ -305,7 +305,7 @@ class Collection(object):
|
||||
response.headers['location'] = \
|
||||
URL(args=(tablename,res.id),scheme=True)
|
||||
return ''
|
||||
except SyntaxError,e: #Exception,e:
|
||||
except SyntaxError as e: #Exception,e:
|
||||
db.rollback()
|
||||
return self.error(400,'BAD REQUEST','Invalid Query:'+e)
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ try:
|
||||
import ldap
|
||||
import ldap.filter
|
||||
ldap.set_option(ldap.OPT_REFERRALS, 0)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.error('missing ldap, try "easy_install python-ldap"')
|
||||
raise e
|
||||
|
||||
@@ -357,7 +357,7 @@ def ldap_auth(server='ldap',
|
||||
con.simple_bind_s(user_dn, password)
|
||||
found = True
|
||||
break
|
||||
except ldap.LDAPError, detail:
|
||||
except ldap.LDAPError as detail:
|
||||
(exc_type, exc_value) = sys.exc_info()[:2]
|
||||
logger.warning("ldap_auth: searching %s for %s resulted in %s: %s\n" % (basedn,
|
||||
filter,
|
||||
@@ -392,7 +392,7 @@ def ldap_auth(server='ldap',
|
||||
con.simple_bind_s(user_dn, password)
|
||||
found = True
|
||||
break
|
||||
except ldap.LDAPError, detail:
|
||||
except ldap.LDAPError as detail:
|
||||
(exc_type, exc_value) = sys.exc_info()[:2]
|
||||
logger.warning("ldap_auth: searching %s for %s resulted in %s: %s\n" % (basedn,
|
||||
filter,
|
||||
@@ -410,18 +410,18 @@ def ldap_auth(server='ldap',
|
||||
store_user_firstname = result[user_firstname_attrib][0].split(' ', 1)[user_firstname_part]
|
||||
else:
|
||||
store_user_firstname = result[user_firstname_attrib][0]
|
||||
except KeyError, e:
|
||||
except KeyError as e:
|
||||
store_user_firstname = None
|
||||
try:
|
||||
if user_lastname_part is not None:
|
||||
store_user_lastname = result[user_lastname_attrib][0].split(' ', 1)[user_lastname_part]
|
||||
else:
|
||||
store_user_lastname = result[user_lastname_attrib][0]
|
||||
except KeyError, e:
|
||||
except KeyError as e:
|
||||
store_user_lastname = None
|
||||
try:
|
||||
store_user_mail = result[user_mail_attrib][0]
|
||||
except KeyError, e:
|
||||
except KeyError as e:
|
||||
store_user_mail = None
|
||||
update_or_insert_values = {'first_name': store_user_firstname,
|
||||
'last_name': store_user_lastname,
|
||||
@@ -451,14 +451,14 @@ def ldap_auth(server='ldap',
|
||||
if not do_manage_groups(username, password, group_mapping):
|
||||
return False
|
||||
return True
|
||||
except ldap.INVALID_CREDENTIALS, e:
|
||||
except ldap.INVALID_CREDENTIALS as e:
|
||||
return False
|
||||
except ldap.LDAPError, e:
|
||||
except ldap.LDAPError as e:
|
||||
import traceback
|
||||
logger.warning('[%s] Error in ldap processing' % str(username))
|
||||
logger.debug(traceback.format_exc())
|
||||
return False
|
||||
except IndexError, ex: # for AD membership test
|
||||
except IndexError as ex: # for AD membership test
|
||||
import traceback
|
||||
logger.warning('[%s] Ldap result indexing error' % str(username))
|
||||
logger.debug(traceback.format_exc())
|
||||
@@ -518,14 +518,14 @@ def ldap_auth(server='ldap',
|
||||
except:
|
||||
try:
|
||||
db_user_id = db(db.auth_user.email == username).select(db.auth_user.id).first().id
|
||||
except AttributeError, e:
|
||||
except AttributeError as e:
|
||||
#
|
||||
# There is no user in local db
|
||||
# We create one
|
||||
# ##############################
|
||||
try:
|
||||
db_user_id = db.auth_user.insert(username=username, first_name=username)
|
||||
except AttributeError, e:
|
||||
except AttributeError as e:
|
||||
db_user_id = db.auth_user.insert(email=username, first_name=username)
|
||||
if not db_user_id:
|
||||
logging.error(
|
||||
|
||||
@@ -174,7 +174,7 @@ server for requests. It can be used for the optional"scope" parameters for Face
|
||||
opener = self.__build_url_opener(self.token_url)
|
||||
try:
|
||||
open_url = opener.open(self.token_url, urlencode(data), self.socket_timeout)
|
||||
except urllib2.HTTPError, e:
|
||||
except urllib2.HTTPError as e:
|
||||
tmp = e.read()
|
||||
raise Exception(tmp)
|
||||
finally:
|
||||
@@ -190,7 +190,7 @@ server for requests. It can be used for the optional"scope" parameters for Face
|
||||
try:
|
||||
tokendata = json.loads(data)
|
||||
current.session.token = tokendata
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
raise Exception("Cannot parse oauth server response %s %s" % (data, e))
|
||||
else: # try facebook style first with x-www-form-encoded
|
||||
tokendata = cgi.parse_qs(data)
|
||||
|
||||
@@ -44,7 +44,7 @@ try:
|
||||
from openid.extensions.sreg import SRegRequest, SRegResponse
|
||||
from openid.store import nonce
|
||||
from openid.consumer.discover import DiscoveryFailure
|
||||
except ImportError, err:
|
||||
except ImportError as err:
|
||||
raise ImportError("OpenIDAuth requires python-openid package")
|
||||
|
||||
DEFAULT = lambda: None
|
||||
|
||||
@@ -133,7 +133,7 @@ def saml2_handler(session, request, config_filename = None):
|
||||
data = client.parse_authn_request_response(
|
||||
unquoted_response, binding, session.saml_outstanding_queries)
|
||||
res['response'] = data if data else {}
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
import traceback
|
||||
res['error'] = traceback.format_exc()
|
||||
return res
|
||||
|
||||
@@ -650,7 +650,7 @@ def replace_components(text, env):
|
||||
pass
|
||||
try:
|
||||
f = f(**b) if isinstance(b, dict) else f(b)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
f = 'ERROR: %s' % e
|
||||
return str(f)
|
||||
|
||||
|
||||
@@ -20,7 +20,8 @@ def removeall(path):
|
||||
def rmgeneric(path, __func__):
|
||||
try:
|
||||
__func__(path)
|
||||
except OSError, (errno, strerror):
|
||||
except OSError as xxx_todo_changeme:
|
||||
(errno, strerror) = xxx_todo_changeme.args
|
||||
print ERROR_STR % {'path': path, 'error': strerror}
|
||||
|
||||
files = [path]
|
||||
|
||||
@@ -69,7 +69,7 @@ class Qdb(bdb.Bdb):
|
||||
method = getattr(self, request['method'])
|
||||
response['result'] = method.__call__(*request['args'],
|
||||
**request.get('kwargs', {}))
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
response['error'] = {'code': 0, 'message': str(e)}
|
||||
# send the result for normal method calls, not for notifications
|
||||
if request.get('id'):
|
||||
@@ -259,7 +259,7 @@ class Qdb(bdb.Bdb):
|
||||
try:
|
||||
self.frame.f_lineno = arg
|
||||
return arg
|
||||
except ValueError, e:
|
||||
except ValueError as e:
|
||||
print '*** Jump failed:', e
|
||||
return False
|
||||
|
||||
@@ -375,7 +375,7 @@ class Qdb(bdb.Bdb):
|
||||
"Return list of auto-completion options for expression"
|
||||
try:
|
||||
obj = self.do_eval(expression)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
return ('', '', str(e))
|
||||
else:
|
||||
name = ''
|
||||
|
||||
@@ -259,7 +259,7 @@ def run(history, statement, env={}):
|
||||
if not name.startswith('__'):
|
||||
try:
|
||||
history.set_global(name, val)
|
||||
except (TypeError, pickle.PicklingError), ex:
|
||||
except (TypeError, pickle.PicklingError) as ex:
|
||||
UNPICKLABLE_TYPES.append(type(val))
|
||||
history.add_unpicklable(statement, new_globals.keys())
|
||||
|
||||
|
||||
@@ -255,7 +255,7 @@ class Sheet:
|
||||
try:
|
||||
r, c = Sheet.pregex.findall(key)
|
||||
r, c = int(r), int(c)
|
||||
except (ValueError, IndexError, TypeError), e:
|
||||
except (ValueError, IndexError, TypeError) as e:
|
||||
error = "%s. %s" % \
|
||||
("Unexpected position parameter",
|
||||
"Must be a key of type 'rncn'")
|
||||
@@ -742,7 +742,7 @@ class Sheet:
|
||||
exec('__value__=' + node.value[1:], {}, self.environment)
|
||||
node.computed_value = self.environment['__value__']
|
||||
del self.environment['__value__']
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
node.computed_value = self.error % dict(error=str(e))
|
||||
self.environment[node.name] = node.computed_value
|
||||
if node.onchange:
|
||||
|
||||
@@ -126,7 +126,7 @@ class WebClient(object):
|
||||
t0 = time.time()
|
||||
self.response = opener.open(self.url, data)
|
||||
self.time = time.time() - t0
|
||||
except urllib2.HTTPError, error:
|
||||
except urllib2.HTTPError as error:
|
||||
# catch HTTP errors
|
||||
self.time = time.time() - t0
|
||||
self.response = error
|
||||
|
||||
@@ -85,7 +85,7 @@ def custom_importer(name, globals=None, locals=None, fromlist=None, level=-1):
|
||||
modules_prefix, globals, locals, [itemname], level)
|
||||
try:
|
||||
result = result or sys.modules[modules_prefix+'.'+itemname]
|
||||
except KeyError, e:
|
||||
except KeyError as e:
|
||||
raise ImportError, 'Cannot import module %s' % str(e)
|
||||
modules_prefix += "." + itemname
|
||||
return result
|
||||
@@ -93,13 +93,13 @@ def custom_importer(name, globals=None, locals=None, fromlist=None, level=-1):
|
||||
# import like "from x import a, b, ..."
|
||||
pname = modules_prefix + "." + name
|
||||
return base_importer(pname, globals, locals, fromlist, level)
|
||||
except ImportError, e1:
|
||||
except ImportError as e1:
|
||||
import_tb = sys.exc_info()[2]
|
||||
try:
|
||||
return NATIVE_IMPORTER(name, globals, locals, fromlist, level)
|
||||
except ImportError, e3:
|
||||
except ImportError as e3:
|
||||
raise ImportError, e1, import_tb # there an import error in the module
|
||||
except Exception, e2:
|
||||
except Exception as e2:
|
||||
raise # there is an error in the module
|
||||
finally:
|
||||
if import_tb:
|
||||
@@ -135,7 +135,7 @@ class TrackImporter(object):
|
||||
# Module maybe loaded for the 1st time so we need to set the date
|
||||
self._update_dates(name, globals, locals, fromlist, level)
|
||||
return result
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
raise # Don't hide something that went wrong
|
||||
|
||||
def _update_dates(self, name, globals, locals, fromlist, level):
|
||||
|
||||
+1
-1
@@ -362,7 +362,7 @@ def get_session(request, other_application='admin'):
|
||||
if not os.path.exists(session_filename):
|
||||
session_filename = generate(session_filename)
|
||||
osession = storage.load_storage(session_filename)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
osession = storage.Storage()
|
||||
return osession
|
||||
|
||||
|
||||
+1
-1
@@ -375,7 +375,7 @@ class Request(Storage):
|
||||
if is_json and not isinstance(res, str):
|
||||
res = json(res)
|
||||
return res
|
||||
except TypeError, e:
|
||||
except TypeError as e:
|
||||
exc_type, exc_value, exc_traceback = sys.exc_info()
|
||||
if len(traceback.extract_tb(exc_traceback)) == 1:
|
||||
raise HTTP(400, "invalid arguments")
|
||||
|
||||
+2
-2
@@ -440,7 +440,7 @@ def wsgibase(environ, responder):
|
||||
|
||||
serve_controller(request, response, session)
|
||||
|
||||
except HTTP, http_response:
|
||||
except HTTP as http_response:
|
||||
|
||||
if static_file:
|
||||
return http_response.to(responder, env=env)
|
||||
@@ -495,7 +495,7 @@ def wsgibase(environ, responder):
|
||||
|
||||
ticket = None
|
||||
|
||||
except RestrictedError, e:
|
||||
except RestrictedError as e:
|
||||
|
||||
if request.body:
|
||||
request.body.close()
|
||||
|
||||
+2
-2
@@ -319,7 +319,7 @@ def crondance(applications_parent, ctype='soft', startup=False, apps=None):
|
||||
lines = [x.strip() for x in cronlines if x.strip(
|
||||
) and not x.strip().startswith('#')]
|
||||
tasks = [parsecronline(cline) for cline in lines]
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logger.error('WEB2PY CRON: crontab read error %s' % e)
|
||||
continue
|
||||
|
||||
@@ -376,7 +376,7 @@ def crondance(applications_parent, ctype='soft', startup=False, apps=None):
|
||||
|
||||
try:
|
||||
cronlauncher(commands, shell=shell).start()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logger.warning(
|
||||
'WEB2PY CRON: Execution error for %s: %s'
|
||||
% (task.get('cmd'), e))
|
||||
|
||||
+1
-1
@@ -230,7 +230,7 @@ def restricted(code, environment=None, layer='Unknown'):
|
||||
except RestrictedError:
|
||||
# do not encapsulate (obfuscate) the original RestrictedError
|
||||
raise
|
||||
except Exception, error:
|
||||
except Exception as error:
|
||||
# extract the exception type and value (used as output message)
|
||||
etype, evalue, tb = sys.exc_info()
|
||||
# XXX Show exception in Wing IDE if running in debugger
|
||||
|
||||
+1
-1
@@ -316,7 +316,7 @@ def load(routes='routes.py', app=None, data=None, rdict=None):
|
||||
symbols = dict(app=app)
|
||||
try:
|
||||
exec (data + '\n') in symbols
|
||||
except SyntaxError, e:
|
||||
except SyntaxError as e:
|
||||
logger.error(
|
||||
'%s has a syntax error and will not be loaded\n' % path
|
||||
+ traceback.format_exc())
|
||||
|
||||
+1
-1
@@ -313,7 +313,7 @@ def executor(queue, task, out):
|
||||
f.write(result)
|
||||
result = 'w2p_special:%s' % temp_path
|
||||
queue.put(TaskReport('COMPLETED', result=result))
|
||||
except BaseException, e:
|
||||
except BaseException as e:
|
||||
tb = traceback.format_exc()
|
||||
queue.put(TaskReport('FAILED', tb=tb))
|
||||
del stdout
|
||||
|
||||
+3
-3
@@ -161,7 +161,7 @@ def env(
|
||||
if import_models:
|
||||
try:
|
||||
run_models_in(environment)
|
||||
except RestrictedError, e:
|
||||
except RestrictedError as e:
|
||||
sys.stderr.write(e.traceback + '\n')
|
||||
sys.exit(1)
|
||||
|
||||
@@ -264,7 +264,7 @@ def run(
|
||||
|
||||
if import_models:
|
||||
BaseAdapter.close_all_instances('commit')
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
print traceback.format_exc()
|
||||
if import_models:
|
||||
BaseAdapter.close_all_instances('rollback')
|
||||
@@ -273,7 +273,7 @@ def run(
|
||||
exec(python_code, _env)
|
||||
if import_models:
|
||||
BaseAdapter.close_all_instances('commit')
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
print traceback.format_exc()
|
||||
if import_models:
|
||||
BaseAdapter.close_all_instances('rollback')
|
||||
|
||||
+2
-2
@@ -2453,7 +2453,7 @@ class SQLFORM(FORM):
|
||||
sfields, keywords))
|
||||
rows = dbset.select(left=left, orderby=orderby,
|
||||
cacheable=True, *selectable_columns)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
response.flash = T('Internal Error')
|
||||
rows = []
|
||||
else:
|
||||
@@ -2651,7 +2651,7 @@ class SQLFORM(FORM):
|
||||
rows = None
|
||||
next_cursor = None
|
||||
error = T("Query Not Supported")
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
rows = None
|
||||
next_cursor = None
|
||||
error = T("Query Not Supported: %s") % e
|
||||
|
||||
+3
-3
@@ -56,7 +56,7 @@ def stream_file_or_304_or_206(
|
||||
try:
|
||||
open = file # this makes no sense but without it GAE cannot open files
|
||||
fp = open(static_file,'rb')
|
||||
except IOError, e:
|
||||
except IOError as e:
|
||||
if e[0] == errno.EISDIR:
|
||||
raise HTTP(403, error_message, web2py_error='file is a directory')
|
||||
elif e[0] == errno.EACCES:
|
||||
@@ -90,7 +90,7 @@ def stream_file_or_304_or_206(
|
||||
bytes = part[1] - part[0] + 1
|
||||
try:
|
||||
stream = open(static_file, 'rb')
|
||||
except IOError, e:
|
||||
except IOError as e:
|
||||
if e[0] in (errno.EISDIR, errno.EACCES):
|
||||
raise HTTP(403)
|
||||
else:
|
||||
@@ -111,7 +111,7 @@ def stream_file_or_304_or_206(
|
||||
headers['Vary'] = 'Accept-Encoding'
|
||||
try:
|
||||
stream = open(static_file, 'rb')
|
||||
except IOError, e:
|
||||
except IOError as e:
|
||||
# this better does not happer when returning an error page ;-)
|
||||
if e[0] in (errno.EISDIR, errno.EACCES):
|
||||
raise HTTP(403)
|
||||
|
||||
@@ -175,7 +175,7 @@ class TestIsUrl(unittest.TestCase):
|
||||
try:
|
||||
x = IS_URL(mode='ftp')
|
||||
x('http://www.google.ca')
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
if str(e) != "invalid mode 'ftp' in IS_URL":
|
||||
self.fail('Wrong exception: ' + str(e))
|
||||
else:
|
||||
@@ -188,7 +188,7 @@ class TestIsUrl(unittest.TestCase):
|
||||
prepend_scheme='ftp')
|
||||
x('http://www.benn.ca') # we can only reasonably know about the
|
||||
# error at calling time
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
if str(e)\
|
||||
!= "allowed_scheme value 'ftp' is not in [None, 'http', 'https']":
|
||||
self.fail('Wrong exception: ' + str(e))
|
||||
@@ -203,7 +203,7 @@ class TestIsUrl(unittest.TestCase):
|
||||
x = IS_URL(prepend_scheme='ftp')
|
||||
x('http://www.benn.ca') # we can only reasonably know about the
|
||||
# error at calling time
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
if str(e)\
|
||||
!= "prepend_scheme='ftp' is not in allowed_schemes=[None, 'http', 'https']":
|
||||
self.fail('Wrong exception: ' + str(e))
|
||||
@@ -215,7 +215,7 @@ class TestIsUrl(unittest.TestCase):
|
||||
|
||||
try:
|
||||
x = IS_URL(allowed_schemes=[None, 'https'])
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
if str(e)\
|
||||
!= "prepend_scheme='http' is not in allowed_schemes=[None, 'https']":
|
||||
self.fail('Wrong exception: ' + str(e))
|
||||
@@ -227,7 +227,7 @@ class TestIsUrl(unittest.TestCase):
|
||||
try:
|
||||
x = IS_URL(allowed_schemes=[None, 'http'],
|
||||
prepend_scheme='https')
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
if str(e)\
|
||||
!= "prepend_scheme='https' is not in allowed_schemes=[None, 'http']":
|
||||
self.fail('Wrong exception: ' + str(e))
|
||||
@@ -239,7 +239,7 @@ class TestIsUrl(unittest.TestCase):
|
||||
try:
|
||||
x = IS_URL(mode='generic', allowed_schemes=[None, 'ftp',
|
||||
'ftps'])
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
if str(e)\
|
||||
!= "prepend_scheme='http' is not in allowed_schemes=[None, 'ftp', 'ftps']":
|
||||
self.fail('Wrong exception: ' + str(e))
|
||||
@@ -253,7 +253,7 @@ class TestIsUrl(unittest.TestCase):
|
||||
x = IS_URL(mode='generic', prepend_scheme='blargg')
|
||||
x('http://www.google.ca')
|
||||
# we can only reasonably know about the error at calling time
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
if not str(e).startswith(
|
||||
"prepend_scheme='blargg' is not in allowed_schemes="):
|
||||
self.fail('Wrong exception: ' + str(e))
|
||||
@@ -265,7 +265,7 @@ class TestIsUrl(unittest.TestCase):
|
||||
try:
|
||||
x = IS_URL(mode='generic', allowed_schemes=[None, 'http'],
|
||||
prepend_scheme='blargg')
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
if str(e)\
|
||||
!= "prepend_scheme='blargg' is not in allowed_schemes=[None, 'http']":
|
||||
self.fail('Wrong exception: ' + str(e))
|
||||
@@ -567,7 +567,7 @@ class TestIsHttpUrl(unittest.TestCase):
|
||||
|
||||
try:
|
||||
IS_HTTP_URL(prepend_scheme='mailto')
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
if str(e)\
|
||||
!= "prepend_scheme='mailto' is not in allowed_schemes=[None, 'http', 'https']":
|
||||
self.fail('Wrong exception: ' + str(e))
|
||||
|
||||
@@ -121,7 +121,7 @@ class TestWeb(LiveTest):
|
||||
|
||||
try:
|
||||
ret = client.Division(a=3, b=0)
|
||||
except SoapFault, sf:
|
||||
except SoapFault as sf:
|
||||
# verify the exception value is ok
|
||||
# assert(sf.faultstring == "float division by zero") # true only in 2.7
|
||||
assert(sf.faultcode == "Server.ZeroDivisionError")
|
||||
@@ -134,7 +134,7 @@ class TestWeb(LiveTest):
|
||||
s = WebClient('http://127.0.0.1:8000/')
|
||||
try:
|
||||
s.post('examples/soap_examples/call/soap', data=xml_request, method="POST")
|
||||
except HTTPError, e:
|
||||
except HTTPError as e:
|
||||
assert(e.msg == 'INTERNAL SERVER ERROR')
|
||||
# check internal server error returned (issue 153)
|
||||
assert(s.status == 500)
|
||||
|
||||
+11
-11
@@ -580,7 +580,7 @@ class Mail(object):
|
||||
payload.attach(p)
|
||||
# it's just a trick to handle the no encryption case
|
||||
payload_in = payload
|
||||
except errors.GPGMEError, ex:
|
||||
except errors.GPGMEError as ex:
|
||||
self.error = "GPG error: %s" % ex.getstring()
|
||||
return False
|
||||
############################################
|
||||
@@ -621,7 +621,7 @@ class Mail(object):
|
||||
p = MIMEBase.MIMEBase("application", 'octet-stream')
|
||||
p.set_payload(cipher.read())
|
||||
payload.attach(p)
|
||||
except errors.GPGMEError, ex:
|
||||
except errors.GPGMEError as ex:
|
||||
self.error = "GPG error: %s" % ex.getstring()
|
||||
return False
|
||||
#######################################################
|
||||
@@ -648,7 +648,7 @@ class Mail(object):
|
||||
# need m2crypto
|
||||
try:
|
||||
from M2Crypto import BIO, SMIME, X509
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.error = "Can't load M2Crypto module"
|
||||
return False
|
||||
msg_bio = BIO.MemoryBuffer(payload_in.as_string())
|
||||
@@ -673,7 +673,7 @@ class Mail(object):
|
||||
else X509.load_cert_string(x509_sign_chainfile)
|
||||
sk.push(chain)
|
||||
s.set_x509_stack(sk)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.error = "Something went wrong on certificate / private key loading: <%s>" % str(e)
|
||||
return False
|
||||
try:
|
||||
@@ -686,7 +686,7 @@ class Mail(object):
|
||||
p7 = s.sign(msg_bio, flags=flags)
|
||||
msg_bio = BIO.MemoryBuffer(payload_in.as_string(
|
||||
)) # Recreate coz sign() has consumed it.
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.error = "Something went wrong on signing: <%s> %s" % (
|
||||
str(e), str(flags))
|
||||
return False
|
||||
@@ -713,7 +713,7 @@ class Mail(object):
|
||||
else:
|
||||
tmp_bio.write(payload_in.as_string())
|
||||
p7 = s.encrypt(tmp_bio)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.error = "Something went wrong on encrypting: <%s>" % str(e)
|
||||
return False
|
||||
|
||||
@@ -805,7 +805,7 @@ class Mail(object):
|
||||
result = server.sendmail(
|
||||
sender, to, payload.as_string())
|
||||
server.quit()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logger.warn('Mail.send failure:%s' % e)
|
||||
self.result = result
|
||||
self.error = e
|
||||
@@ -5722,7 +5722,7 @@ class Service(object):
|
||||
if hasattr(s, 'as_list'):
|
||||
s = s.as_list()
|
||||
return return_response(id, s)
|
||||
except Service.JsonRpcException, e:
|
||||
except Service.JsonRpcException as e:
|
||||
return return_error(id, e.code, e.info)
|
||||
except:
|
||||
etype, eval, etb = sys.exc_info()
|
||||
@@ -5803,7 +5803,7 @@ class Service(object):
|
||||
|
||||
try:
|
||||
must_respond = validate(data)
|
||||
except Service.JsonRpcException, e:
|
||||
except Service.JsonRpcException as e:
|
||||
return return_error(None, e.code, e.info)
|
||||
|
||||
id, method, params = data.get('id'), data['method'], data.get('params', '')
|
||||
@@ -5820,9 +5820,9 @@ class Service(object):
|
||||
return return_response(id, s)
|
||||
else:
|
||||
return ''
|
||||
except HTTP, e:
|
||||
except HTTP as e:
|
||||
raise e
|
||||
except Service.JsonRpcException, e:
|
||||
except Service.JsonRpcException as e:
|
||||
return return_error(id, e.code, e.info)
|
||||
except:
|
||||
etype, eval, etb = sys.exc_info()
|
||||
|
||||
+1
-1
@@ -196,7 +196,7 @@ def secure_loads(data, encryption_key, hash_key=None, compression_level=None):
|
||||
if compression_level:
|
||||
data = zlib.decompress(data)
|
||||
return pickle.loads(data)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
return None
|
||||
|
||||
### compute constant CTOKENS
|
||||
|
||||
+1
-1
@@ -512,7 +512,7 @@ class web2pyDialog(object):
|
||||
interfaces=options.interfaces)
|
||||
|
||||
thread.start_new_thread(self.server.start, ())
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.button_start.configure(state='normal')
|
||||
return self.error(str(e))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user