Fix PL/Python ereport() test to work on Python 2.3.
authorTom Lane
Sat, 9 Apr 2016 20:44:54 +0000 (16:44 -0400)
committerTom Lane
Sat, 9 Apr 2016 20:44:54 +0000 (16:44 -0400)
Per buildfarm.

Pavel Stehule

src/pl/plpython/expected/plpython_test.out
src/pl/plpython/sql/plpython_test.sql

index 05caba17870077a873632a916b6c015f5ac6a04b..bdff07a5fb09471cdf84e652159effe108c50d78 100644 (file)
@@ -150,22 +150,26 @@ RETURNS void AS $$
 kwargs = { "message":_message, "detail":_detail, "hint":_hint,
            "sqlstate":_sqlstate, "schema":_schema, "table":_table,
            "column":_column, "datatype":_datatype, "constraint":_constraint }
-# ignore None values
-plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v))
+# ignore None values - should work on Python2.3
+dict = {}
+for k in kwargs:
+   if kwargs[k] is not None:
+       dict[k] = kwargs[k]
+plpy.error(**dict)
 $$ LANGUAGE plpythonu;
 SELECT raise_exception('hello', 'world');
 ERROR:  plpy.Error: hello
 DETAIL:  world
 CONTEXT:  Traceback (most recent call last):
-  PL/Python function "raise_exception", line 6, in 
-    plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v))
+  PL/Python function "raise_exception", line 10, in 
+    plpy.error(**dict)
 PL/Python function "raise_exception"
 SELECT raise_exception('message text', 'detail text', _sqlstate => 'YY333');
 ERROR:  plpy.Error: message text
 DETAIL:  detail text
 CONTEXT:  Traceback (most recent call last):
-  PL/Python function "raise_exception", line 6, in 
-    plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v))
+  PL/Python function "raise_exception", line 10, in 
+    plpy.error(**dict)
 PL/Python function "raise_exception"
 SELECT raise_exception(_message => 'message text',
                        _detail => 'detail text',
@@ -180,8 +184,8 @@ ERROR:  plpy.Error: message text
 DETAIL:  detail text
 HINT:  hint text
 CONTEXT:  Traceback (most recent call last):
-  PL/Python function "raise_exception", line 6, in 
-    plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v))
+  PL/Python function "raise_exception", line 10, in 
+    plpy.error(**dict)
 PL/Python function "raise_exception"
 SELECT raise_exception(_message => 'message text',
                        _hint => 'hint text',
@@ -191,8 +195,8 @@ SELECT raise_exception(_message => 'message text',
 ERROR:  plpy.Error: message text
 HINT:  hint text
 CONTEXT:  Traceback (most recent call last):
-  PL/Python function "raise_exception", line 6, in 
-    plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v))
+  PL/Python function "raise_exception", line 10, in 
+    plpy.error(**dict)
 PL/Python function "raise_exception"
 DO $$
 DECLARE
index 6e5b535ceb7fc22756371abadeae501409e3f45a..b74c68fe3e64da73f9ea846fc4e7a298ceef1e88 100644 (file)
@@ -102,8 +102,12 @@ RETURNS void AS $$
 kwargs = { "message":_message, "detail":_detail, "hint":_hint,
            "sqlstate":_sqlstate, "schema":_schema, "table":_table,
            "column":_column, "datatype":_datatype, "constraint":_constraint }
-# ignore None values
-plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v))
+# ignore None values - should work on Python2.3
+dict = {}
+for k in kwargs:
+   if kwargs[k] is not None:
+       dict[k] = kwargs[k]
+plpy.error(**dict)
 $$ LANGUAGE plpythonu;
 
 SELECT raise_exception('hello', 'world');