Author: Amaury Forgeot d'Arc <[email protected]>
Branch: py3k
Changeset: r50667:14e9568e4282
Date: 2011-12-18 17:05 +0100
http://bitbucket.org/pypy/pypy/changeset/14e9568e4282/
Log: Fix some syntax errors in lib_pypy
diff --git a/lib_pypy/_rpyc_support.py b/lib_pypy/_rpyc_support.py
--- a/lib_pypy/_rpyc_support.py
+++ b/lib_pypy/_rpyc_support.py
@@ -7,7 +7,7 @@
try:
conn = connect("localhost", DEFAULT_SERVER_PORT, SlaveService,
config=dict(call_by_value_for_builtin_mutable_types=True))
-except socket.error, e:
+except socket.error as e:
raise ImportError("Error while connecting: " + str(e))
diff --git a/lib_pypy/_sqlite3.py b/lib_pypy/_sqlite3.py
--- a/lib_pypy/_sqlite3.py
+++ b/lib_pypy/_sqlite3.py
@@ -604,7 +604,7 @@
def authorizer(userdata, action, arg1, arg2, dbname, source):
try:
return int(callback(action, arg1, arg2, dbname, source))
- except Exception, e:
+ except Exception as e:
return SQLITE_DENY
c_authorizer = AUTHORIZER(authorizer)
@@ -651,7 +651,7 @@
if not aggregate_ptr[0]:
try:
aggregate = cls()
- except Exception, e:
+ except Exception as e:
msg = ("user-defined aggregate's '__init__' "
"method raised error")
sqlite.sqlite3_result_error(context, msg, len(msg))
@@ -665,7 +665,7 @@
params = _convert_params(context, argc, c_params)
try:
aggregate.step(*params)
- except Exception, e:
+ except Exception as e:
msg = ("user-defined aggregate's 'step' "
"method raised error")
sqlite.sqlite3_result_error(context, msg, len(msg))
@@ -681,7 +681,7 @@
aggregate = self.aggregate_instances[aggregate_ptr[0]]
try:
val = aggregate.finalize()
- except Exception, e:
+ except Exception as e:
msg = ("user-defined aggregate's 'finalize' "
"method raised error")
sqlite.sqlite3_result_error(context, msg, len(msg))
@@ -788,7 +788,7 @@
if self.statement.kind == DML:
self.connection._begin()
else:
- raise ProgrammingError, "executemany is only for DML statements"
+ raise ProgrammingError("executemany is only for DML statements")
self.rowcount = 0
for params in many_params:
@@ -912,7 +912,7 @@
def __init__(self, connection, sql):
self.statement = None
if not isinstance(sql, str):
- raise ValueError, "sql must be a string"
+ raise ValueError("sql must be a string")
self.con = connection
self.sql = sql # DEBUG ONLY
first_word = self._statement_kind = sql.lstrip().split(" ")[0].upper()
@@ -941,8 +941,8 @@
raise self.con._get_exception(ret)
self.con._remember_statement(self)
if _check_remaining_sql(next_char.value):
- raise Warning, "One and only one statement required: %r" % (
- next_char.value,)
+ raise Warning("One and only one statement required: %r" %
+ (next_char.value,))
# sql_char should remain alive until here
self._build_row_cast_map()
@@ -1013,7 +1013,8 @@
elif type(param) is buffer:
sqlite.sqlite3_bind_blob(self.statement, idx, str(param),
len(param), SQLITE_TRANSIENT)
else:
- raise InterfaceError, "parameter type %s is not supported" %
str(type(param))
+ raise InterfaceError("parameter type %s is not supported" %
+ type(param))
def set_params(self, params):
ret = sqlite.sqlite3_reset(self.statement)
@@ -1042,11 +1043,11 @@
for idx in range(1,
sqlite.sqlite3_bind_parameter_count(self.statement) + 1):
param_name =
sqlite.sqlite3_bind_parameter_name(self.statement, idx)
if param_name is None:
- raise ProgrammingError, "need named parameters"
+ raise ProgrammingError("need named parameters")
param_name = param_name[1:]
try:
param = params[param_name]
- except KeyError, e:
+ except KeyError as e:
raise ProgrammingError("missing parameter '%s'" %param)
self.set_param(idx, param)
@@ -1257,7 +1258,7 @@
params = _convert_params(context, nargs, c_params)
try:
val = real_cb(*params)
- except Exception, e:
+ except Exception as e:
msg = "user-defined function raised exception"
sqlite.sqlite3_result_error(context, msg, len(msg))
else:
diff --git a/lib_pypy/dbm.py b/lib_pypy/dbm.py
--- a/lib_pypy/dbm.py
+++ b/lib_pypy/dbm.py
@@ -165,7 +165,7 @@
'c': os.O_RDWR | os.O_CREAT,
'n': os.O_RDWR | os.O_CREAT | os.O_TRUNC,
}[flag]
- except KeyError, e:
+ except KeyError as e:
raise error("arg 2 to open should be 'r', 'w', 'c', or 'n'")
a_db = getattr(lib, funcs['open'])(filename, openflag, mode)
diff --git a/lib_pypy/disassembler.py b/lib_pypy/disassembler.py
--- a/lib_pypy/disassembler.py
+++ b/lib_pypy/disassembler.py
@@ -82,7 +82,7 @@
print "Disassembly of %s:" % name
try:
dis(x1)
- except TypeError, msg:
+ except TypeError as msg:
print "Sorry:", msg
print
elif hasattr(x, 'co_code'):
diff --git a/lib_pypy/greenlet.py b/lib_pypy/greenlet.py
--- a/lib_pypy/greenlet.py
+++ b/lib_pypy/greenlet.py
@@ -77,7 +77,7 @@
try:
unbound_method = getattr(_continulet, methodname)
args = unbound_method(current, *args, to=target)
- except GreenletExit, e:
+ except GreenletExit as e:
args = (e,)
finally:
_tls.current = current
@@ -139,6 +139,6 @@
def _greenlet_throw(greenlet, exc, value, tb):
_tls.current = greenlet
try:
- raise exc, value, tb
+ raise value.with_traceback(tb)
finally:
_continuation.permute(greenlet, greenlet.parent)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit