Commit f16d5226 authored by Peter Eisentraut's avatar Peter Eisentraut

PL/Python: Make tests pass with Python 3.5

The error message wording for AttributeError has changed in Python 3.5.
For the plpython_error test, add a new expected file.  In the
plpython_subtransaction test, we didn't really care what the exception
is, only that it is something coming from Python.  So use a generic
exception instead, which has a message that doesn't vary across
versions.
parent d67616c7
Guide to alternative expected files:
plpython_error_0.out Python 2.4 and older
plpython_error_5.out Python 3.5 and newer
plpython_unicode.out server encoding != SQL_ASCII
plpython_unicode_3.out server encoding == SQL_ASCII
......
This diff is collapsed.
......@@ -19,7 +19,7 @@ try:
if what_error == "SPI":
plpy.execute("INSERT INTO subtransaction_tbl VALUES ('oops')")
elif what_error == "Python":
plpy.attribute_error
raise Exception("Python exception")
except:
exc = False
subxact.__exit__(*sys.exc_info())
......@@ -58,10 +58,10 @@ SELECT * FROM subtransaction_tbl;
TRUNCATE subtransaction_tbl;
SELECT subtransaction_test('Python');
ERROR: AttributeError: 'module' object has no attribute 'attribute_error'
ERROR: Exception: Python exception
CONTEXT: Traceback (most recent call last):
PL/Python function "subtransaction_test", line 13, in <module>
plpy.attribute_error
raise Exception("Python exception")
PL/Python function "subtransaction_test"
SELECT * FROM subtransaction_tbl;
i
......@@ -78,7 +78,7 @@ with plpy.subtransaction():
if what_error == "SPI":
plpy.execute("INSERT INTO subtransaction_tbl VALUES ('oops')")
elif what_error == "Python":
plpy.attribute_error
raise Exception("Python exception")
$$ LANGUAGE plpythonu;
SELECT subtransaction_ctx_test();
subtransaction_ctx_test
......@@ -110,10 +110,10 @@ SELECT * FROM subtransaction_tbl;
TRUNCATE subtransaction_tbl;
SELECT subtransaction_ctx_test('Python');
ERROR: AttributeError: 'module' object has no attribute 'attribute_error'
ERROR: Exception: Python exception
CONTEXT: Traceback (most recent call last):
PL/Python function "subtransaction_ctx_test", line 8, in <module>
plpy.attribute_error
raise Exception("Python exception")
PL/Python function "subtransaction_ctx_test"
SELECT * FROM subtransaction_tbl;
i
......
......@@ -19,7 +19,7 @@ try:
if what_error == "SPI":
plpy.execute("INSERT INTO subtransaction_tbl VALUES ('oops')")
elif what_error == "Python":
plpy.attribute_error
raise Exception("Python exception")
except:
exc = False
subxact.__exit__(*sys.exc_info())
......@@ -58,10 +58,10 @@ SELECT * FROM subtransaction_tbl;
TRUNCATE subtransaction_tbl;
SELECT subtransaction_test('Python');
ERROR: AttributeError: 'module' object has no attribute 'attribute_error'
ERROR: Exception: Python exception
CONTEXT: Traceback (most recent call last):
PL/Python function "subtransaction_test", line 13, in <module>
plpy.attribute_error
raise Exception("Python exception")
PL/Python function "subtransaction_test"
SELECT * FROM subtransaction_tbl;
i
......@@ -78,7 +78,7 @@ with plpy.subtransaction():
if what_error == "SPI":
plpy.execute("INSERT INTO subtransaction_tbl VALUES ('oops')")
elif what_error == "Python":
plpy.attribute_error
raise Exception("Python exception")
$$ LANGUAGE plpythonu;
ERROR: could not compile PL/Python function "subtransaction_ctx_test"
DETAIL: SyntaxError: invalid syntax (line 3)
......
......@@ -19,7 +19,7 @@ try:
if what_error == "SPI":
plpy.execute("INSERT INTO subtransaction_tbl VALUES ('oops')")
elif what_error == "Python":
plpy.attribute_error
raise Exception("Python exception")
except:
exc = False
subxact.__exit__(*sys.exc_info())
......@@ -58,10 +58,10 @@ SELECT * FROM subtransaction_tbl;
TRUNCATE subtransaction_tbl;
SELECT subtransaction_test('Python');
ERROR: AttributeError: 'module' object has no attribute 'attribute_error'
ERROR: Exception: Python exception
CONTEXT: Traceback (most recent call last):
PL/Python function "subtransaction_test", line 13, in <module>
plpy.attribute_error
raise Exception("Python exception")
PL/Python function "subtransaction_test"
SELECT * FROM subtransaction_tbl;
i
......@@ -78,7 +78,7 @@ with plpy.subtransaction():
if what_error == "SPI":
plpy.execute("INSERT INTO subtransaction_tbl VALUES ('oops')")
elif what_error == "Python":
plpy.attribute_error
raise Exception("Python exception")
$$ LANGUAGE plpythonu;
ERROR: could not compile PL/Python function "subtransaction_ctx_test"
DETAIL: SyntaxError: invalid syntax (<string>, line 3)
......
......@@ -23,7 +23,7 @@ try:
if what_error == "SPI":
plpy.execute("INSERT INTO subtransaction_tbl VALUES ('oops')")
elif what_error == "Python":
plpy.attribute_error
raise Exception("Python exception")
except:
exc = False
subxact.__exit__(*sys.exc_info())
......@@ -53,7 +53,7 @@ with plpy.subtransaction():
if what_error == "SPI":
plpy.execute("INSERT INTO subtransaction_tbl VALUES ('oops')")
elif what_error == "Python":
plpy.attribute_error
raise Exception("Python exception")
$$ LANGUAGE plpythonu;
SELECT subtransaction_ctx_test();
......
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