Commit b55413d7 authored by Peter Eisentraut's avatar Peter Eisentraut

Modernize Python exception syntax in documentation

Change the exception syntax used in the documentation to use the more
current

    except Exception as ex:

rather than the old

    except Exception, ex:

We keep the old syntax in the test code since Python <2.6 is still
supported there, but the documentation might as well use the modern
syntax.
parent 0ce38730
...@@ -1227,7 +1227,7 @@ except spiexceptions.DivisionByZero: ...@@ -1227,7 +1227,7 @@ except spiexceptions.DivisionByZero:
return "denominator cannot equal zero" return "denominator cannot equal zero"
except spiexceptions.UniqueViolation: except spiexceptions.UniqueViolation:
return "already have that fraction" return "already have that fraction"
except plpy.SPIError, e: except plpy.SPIError as e:
return "other error, SQLSTATE %s" % e.sqlstate return "other error, SQLSTATE %s" % e.sqlstate
else: else:
return "fraction inserted" return "fraction inserted"
...@@ -1274,7 +1274,7 @@ CREATE FUNCTION transfer_funds() RETURNS void AS $$ ...@@ -1274,7 +1274,7 @@ CREATE FUNCTION transfer_funds() RETURNS void AS $$
try: try:
plpy.execute("UPDATE accounts SET balance = balance - 100 WHERE account_name = 'joe'") plpy.execute("UPDATE accounts SET balance = balance - 100 WHERE account_name = 'joe'")
plpy.execute("UPDATE accounts SET balance = balance + 100 WHERE account_name = 'mary'") plpy.execute("UPDATE accounts SET balance = balance + 100 WHERE account_name = 'mary'")
except plpy.SPIError, e: except plpy.SPIError as e:
result = "error transferring funds: %s" % e.args result = "error transferring funds: %s" % e.args
else: else:
result = "funds transferred correctly" result = "funds transferred correctly"
...@@ -1306,7 +1306,7 @@ try: ...@@ -1306,7 +1306,7 @@ try:
with plpy.subtransaction(): with plpy.subtransaction():
plpy.execute("UPDATE accounts SET balance = balance - 100 WHERE account_name = 'joe'") plpy.execute("UPDATE accounts SET balance = balance - 100 WHERE account_name = 'joe'")
plpy.execute("UPDATE accounts SET balance = balance + 100 WHERE account_name = 'mary'") plpy.execute("UPDATE accounts SET balance = balance + 100 WHERE account_name = 'mary'")
except plpy.SPIError, e: except plpy.SPIError as e:
result = "error transferring funds: %s" % e.args result = "error transferring funds: %s" % e.args
else: else:
result = "funds transferred correctly" result = "funds transferred correctly"
...@@ -1357,7 +1357,7 @@ try: ...@@ -1357,7 +1357,7 @@ try:
raise raise
else: else:
subxact.exit(None, None, None) subxact.exit(None, None, None)
except plpy.SPIError, e: except plpy.SPIError as e:
result = "error transferring funds: %s" % e.args result = "error transferring funds: %s" % e.args
else: else:
result = "funds transferred correctly" result = "funds transferred correctly"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment