Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc7a141a

Browse files
committed
Fix PL/Python ereport() test to work on Python 2.3.
Per buildfarm.Pavel Stehule
1 parent08e7854 commitc7a141a

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

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

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -150,22 +150,26 @@ RETURNS void AS $$
150150
kwargs = { "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;
156160
SELECT raise_exception('hello', 'world');
157161
ERROR: plpy.Error: hello
158162
DETAIL: world
159163
CONTEXT: Traceback (most recent call last):
160-
PL/Python function "raise_exception", line6, in <module>
161-
plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v))
164+
PL/Python function "raise_exception", line10, in <module>
165+
plpy.error(**dict)
162166
PL/Python function "raise_exception"
163167
SELECT raise_exception('message text', 'detail text', _sqlstate => 'YY333');
164168
ERROR: plpy.Error: message text
165169
DETAIL: detail text
166170
CONTEXT: Traceback (most recent call last):
167-
PL/Python function "raise_exception", line6, in <module>
168-
plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v))
171+
PL/Python function "raise_exception", line10, in <module>
172+
plpy.error(**dict)
169173
PL/Python function "raise_exception"
170174
SELECT raise_exception(_message => 'message text',
171175
_detail => 'detail text',
@@ -180,8 +184,8 @@ ERROR: plpy.Error: message text
180184
DETAIL: detail text
181185
HINT: hint text
182186
CONTEXT: Traceback (most recent call last):
183-
PL/Python function "raise_exception", line6, in <module>
184-
plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v))
187+
PL/Python function "raise_exception", line10, in <module>
188+
plpy.error(**dict)
185189
PL/Python function "raise_exception"
186190
SELECT raise_exception(_message => 'message text',
187191
_hint => 'hint text',
@@ -191,8 +195,8 @@ SELECT raise_exception(_message => 'message text',
191195
ERROR: plpy.Error: message text
192196
HINT: hint text
193197
CONTEXT: Traceback (most recent call last):
194-
PL/Python function "raise_exception", line6, in <module>
195-
plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v))
198+
PL/Python function "raise_exception", line10, in <module>
199+
plpy.error(**dict)
196200
PL/Python function "raise_exception"
197201
DO $$
198202
DECLARE

‎src/pl/plpython/sql/plpython_test.sql

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,12 @@ RETURNS void AS $$
102102
kwargs= {"message":_message,"detail":_detail,"hint":_hint,
103103
"sqlstate":_sqlstate,"schema":_schema,"table":_table,
104104
"column":_column,"datatype":_datatype,"constraint":_constraint }
105-
# ignore None values
106-
plpy.error(**dict((k, v) for k, vin iter(kwargs.items()) if v))
105+
# ignore None values - should work on Python2.3
106+
dict= {}
107+
for kin kwargs:
108+
if kwargs[k] is not None:
109+
dict[k]= kwargs[k]
110+
plpy.error(**dict)
107111
$$ LANGUAGE plpythonu;
108112

109113
SELECT raise_exception('hello','world');

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp