@@ -150,22 +150,26 @@ RETURNS void AS $$
150150kwargs = { "message":_message, "detail":_detail, "hint":_hint,
151151 "sqlstate":_sqlstate, "schema":_schema, "table":_table,
152152 "column":_column, "datatype":_datatype, "constraint":_constraint }
153- # ignore None values
154- plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v))
153+ # ignore None values - should work on Python2.3
154+ dict = {}
155+ for k in kwargs:
156+ if kwargs[k] is not None:
157+ dict[k] = kwargs[k]
158+ plpy.error(**dict)
155159$$ LANGUAGE plpythonu;
156160SELECT raise_exception('hello', 'world');
157161ERROR: plpy.Error: hello
158162DETAIL: world
159163CONTEXT: Traceback (most recent call last):
160- PL/Python function "raise_exception", line 6 , in <module>
161- plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v) )
164+ PL/Python function "raise_exception", line 10 , in <module>
165+ plpy.error(**dict)
162166PL/Python function "raise_exception"
163167SELECT raise_exception('message text', 'detail text', _sqlstate => 'YY333');
164168ERROR: plpy.Error: message text
165169DETAIL: detail text
166170CONTEXT: Traceback (most recent call last):
167- PL/Python function "raise_exception", line 6 , in <module>
168- plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v) )
171+ PL/Python function "raise_exception", line 10 , in <module>
172+ plpy.error(**dict)
169173PL/Python function "raise_exception"
170174SELECT raise_exception(_message => 'message text',
171175 _detail => 'detail text',
@@ -180,8 +184,8 @@ ERROR: plpy.Error: message text
180184DETAIL: detail text
181185HINT: hint text
182186CONTEXT: Traceback (most recent call last):
183- PL/Python function "raise_exception", line 6 , in <module>
184- plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v) )
187+ PL/Python function "raise_exception", line 10 , in <module>
188+ plpy.error(**dict)
185189PL/Python function "raise_exception"
186190SELECT raise_exception(_message => 'message text',
187191 _hint => 'hint text',
@@ -191,8 +195,8 @@ SELECT raise_exception(_message => 'message text',
191195ERROR: plpy.Error: message text
192196HINT: hint text
193197CONTEXT: Traceback (most recent call last):
194- PL/Python function "raise_exception", line 6 , in <module>
195- plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v) )
198+ PL/Python function "raise_exception", line 10 , in <module>
199+ plpy.error(**dict)
196200PL/Python function "raise_exception"
197201DO $$
198202DECLARE
0 commit comments