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

Commit04aad40

Browse files
committed
Drop support for Python 2.3
There is no specific reason for this right now, but keeping support forold Python versions around indefinitely increases the maintenanceburden. The oldest supported Python version is now Python 2.4, which isstill shipped in RHEL/CentOS 5 by default.In configure, add a check for the required Python version and give afriendly error message for an old version, instead of relying on anobscure build error later on.
1 parent0bf41dd commit04aad40

File tree

9 files changed

+27
-45
lines changed

9 files changed

+27
-45
lines changed

‎config/python.m4

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ else
3131
fi
3232
AC_MSG_CHECKING([Python configuration directory])
3333
python_majorversion=`${PYTHON} -c "import sys; print(sys.version[[0]])"`
34+
python_minorversion=`${PYTHON} -c "import sys; print(sys.version[[2]])"`
3435
python_version=`${PYTHON} -c "import sys; print(sys.version[[:3]])"`
3536
python_configdir=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('LIBPL'))))"`
3637
AC_MSG_RESULT([$python_configdir])

‎configure

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7588,6 +7588,7 @@ fi
75887588
{$as_echo"$as_me:${as_lineno-$LINENO}: checking Python configuration directory">&5
75897589
$as_echo_n"checking Python configuration directory...">&6; }
75907590
python_majorversion=`${PYTHON} -c"import sys; print(sys.version[0])"`
7591+
python_minorversion=`${PYTHON} -c"import sys; print(sys.version[2])"`
75917592
python_version=`${PYTHON} -c"import sys; print(sys.version[:3])"`
75927593
python_configdir=`${PYTHON} -c"import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('LIBPL'))))"`
75937594
{$as_echo"$as_me:${as_lineno-$LINENO}: result:$python_configdir">&5
@@ -7698,6 +7699,9 @@ $as_echo "${python_libspec} ${python_additional_libs}" >&6; }
76987699

76997700

77007701

7702+
iftest"$python_majorversion" -lt 3 -a"$python_minorversion" -lt 4;then
7703+
as_fn_error$?"Python version$python_version is too old (version 2.4 or later is required)""$LINENO" 5
7704+
fi
77017705
fi
77027706

77037707
iftest"$cross_compiling" = yes&&test -z"$with_system_tzdata";then

‎configure.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,9 @@ fi
927927
if test "$with_python" = yes; then
928928
PGAC_PATH_PYTHON
929929
PGAC_CHECK_PYTHON_EMBED_SETUP
930+
if test "$python_majorversion" -lt 3 -a "$python_minorversion" -lt 4; then
931+
AC_MSG_ERROR([Python version $python_version is too old (version 2.4 or later is required)])
932+
fi
930933
fi
931934

932935
if test "$cross_compiling" = yes && test -z "$with_system_tzdata"; then

‎contrib/hstore_plpython/expected/hstore_plpython.out

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ LANGUAGE plpythonu
66
TRANSFORM FOR TYPE hstore
77
AS $$
88
assert isinstance(val, dict)
9-
i = list(val.items())
10-
i.sort()
11-
plpy.info(i)
9+
plpy.info(sorted(val.items()))
1210
return len(val)
1311
$$;
1412
SELECT test1('aa=>bb, cc=>NULL'::hstore);
@@ -24,9 +22,7 @@ LANGUAGE plpython2u
2422
TRANSFORM FOR TYPE hstore
2523
AS $$
2624
assert isinstance(val, dict)
27-
i = list(val.items())
28-
i.sort()
29-
plpy.info(i)
25+
plpy.info(sorted(val.items()))
3026
return len(val)
3127
$$;
3228
SELECT test1n('aa=>bb, cc=>NULL'::hstore);

‎contrib/hstore_plpython/sql/hstore_plpython.sql

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ LANGUAGE plpythonu
77
TRANSFORM FOR TYPE hstore
88
AS $$
99
assert isinstance(val, dict)
10-
i= list(val.items())
11-
i.sort()
12-
plpy.info(i)
10+
plpy.info(sorted(val.items()))
1311
return len(val)
1412
$$;
1513

@@ -22,9 +20,7 @@ LANGUAGE plpython2u
2220
TRANSFORM FOR TYPE hstore
2321
AS $$
2422
assert isinstance(val, dict)
25-
i= list(val.items())
26-
i.sort()
27-
plpy.info(i)
23+
plpy.info(sorted(val.items()))
2824
return len(val)
2925
$$;
3026

‎doc/src/sgml/installation.sgml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,7 @@ su - postgres
193193
language, you need a <productname>Python</productname>
194194
installation with the header files and
195195
the <application>distutils</application> module. The minimum
196-
required version is <productname>Python</productname> 2.3.
197-
(To work with function arguments of type <type>numeric</>, a 2.3.x
198-
installation must include the separately-available <filename>cdecimal</>
199-
module; note the <application>PL/Python</> regression tests
200-
will not pass if that is missing.)
196+
required version is <productname>Python</productname> 2.4.
201197
<productname>Python 3</productname> is supported if it's
202198
version 3.1 or later; but see
203199
<![%standalone-include[the <application>PL/Python</> documentation]]>

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

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -94,26 +94,22 @@ kwargs = {
9494
"column_name": _column_name, "datatype_name": _datatype_name,
9595
"constraint_name": _constraint_name
9696
}
97-
# ignore None values - should work on Python2.3
98-
dict = {}
99-
for k in kwargs:
100-
if kwargs[k] is not None:
101-
dict[k] = kwargs[k]
102-
plpy.error(**dict)
97+
# ignore None values
98+
plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v))
10399
$$ LANGUAGE plpythonu;
104100
SELECT raise_exception('hello', 'world');
105101
ERROR: plpy.Error: hello
106102
DETAIL: world
107103
CONTEXT: Traceback (most recent call last):
108-
PL/Python function "raise_exception", line13, in <module>
109-
plpy.error(**dict)
104+
PL/Python function "raise_exception", line9, in <module>
105+
plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v))
110106
PL/Python function "raise_exception"
111107
SELECT raise_exception('message text', 'detail text', _sqlstate => 'YY333');
112108
ERROR: plpy.Error: message text
113109
DETAIL: detail text
114110
CONTEXT: Traceback (most recent call last):
115-
PL/Python function "raise_exception", line13, in <module>
116-
plpy.error(**dict)
111+
PL/Python function "raise_exception", line9, in <module>
112+
plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v))
117113
PL/Python function "raise_exception"
118114
SELECT raise_exception(_message => 'message text',
119115
_detail => 'detail text',
@@ -128,8 +124,8 @@ ERROR: plpy.Error: message text
128124
DETAIL: detail text
129125
HINT: hint text
130126
CONTEXT: Traceback (most recent call last):
131-
PL/Python function "raise_exception", line13, in <module>
132-
plpy.error(**dict)
127+
PL/Python function "raise_exception", line9, in <module>
128+
plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v))
133129
PL/Python function "raise_exception"
134130
SELECT raise_exception(_message => 'message text',
135131
_hint => 'hint text',
@@ -139,8 +135,8 @@ SELECT raise_exception(_message => 'message text',
139135
ERROR: plpy.Error: message text
140136
HINT: hint text
141137
CONTEXT: Traceback (most recent call last):
142-
PL/Python function "raise_exception", line13, in <module>
143-
plpy.error(**dict)
138+
PL/Python function "raise_exception", line9, in <module>
139+
plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v))
144140
PL/Python function "raise_exception"
145141
DO $$
146142
DECLARE

‎src/pl/plpython/plpy_typeio.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -521,15 +521,9 @@ PLy_input_datum_func2(PLyDatumToOb *arg, MemoryContext arg_mcxt, Oid typeOid, He
521521
staticPyObject*
522522
PLyBool_FromBool(PLyDatumToOb*arg,Datumd)
523523
{
524-
/*
525-
* We would like to use Py_RETURN_TRUE and Py_RETURN_FALSE here for
526-
* generating SQL from trigger functions, but those are only supported in
527-
* Python >= 2.4, and we support older versions.
528-
* http://docs.python.org/api/boolObjects.html
529-
*/
530524
if (DatumGetBool(d))
531-
returnPyBool_FromLong(1);
532-
returnPyBool_FromLong(0);
525+
Py_RETURN_TRUE;
526+
Py_RETURN_FALSE;
533527
}
534528

535529
staticPyObject*

‎src/pl/plpython/sql/plpython_ereport.sql

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,8 @@ kwargs = {
5555
"column_name": _column_name,"datatype_name": _datatype_name,
5656
"constraint_name": _constraint_name
5757
}
58-
# ignore None values - should work on Python2.3
59-
dict= {}
60-
for kin kwargs:
61-
if kwargs[k] is not None:
62-
dict[k]= kwargs[k]
63-
plpy.error(**dict)
58+
# ignore None values
59+
plpy.error(**dict((k, v) for k, vin iter(kwargs.items()) if v))
6460
$$ LANGUAGE plpythonu;
6561

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp