]> granicus.if.org Git - postgresql/commitdiff
Drop support for Python 2.3
authorPeter Eisentraut <peter_e@gmx.net>
Tue, 21 Feb 2017 14:27:02 +0000 (09:27 -0500)
committerPeter Eisentraut <peter_e@gmx.net>
Tue, 21 Feb 2017 14:49:22 +0000 (09:49 -0500)
There is no specific reason for this right now, but keeping support for
old Python versions around indefinitely increases the maintenance
burden.  The oldest supported Python version is now Python 2.4, which is
still shipped in RHEL/CentOS 5 by default.

In configure, add a check for the required Python version and give a
friendly error message for an old version, instead of relying on an
obscure build error later on.

config/python.m4
configure
configure.in
contrib/hstore_plpython/expected/hstore_plpython.out
contrib/hstore_plpython/sql/hstore_plpython.sql
doc/src/sgml/installation.sgml
src/pl/plpython/expected/plpython_ereport.out
src/pl/plpython/plpy_typeio.c
src/pl/plpython/sql/plpython_ereport.sql

index b605212bea16a90fe1e8a705263602fb2c0a6de9..7f775e77d239c722b3cb3a5145c71057093a448b 100644 (file)
@@ -31,6 +31,7 @@ else
 fi
 AC_MSG_CHECKING([Python configuration directory])
 python_majorversion=`${PYTHON} -c "import sys; print(sys.version[[0]])"`
+python_minorversion=`${PYTHON} -c "import sys; print(sys.version[[2]])"`
 python_version=`${PYTHON} -c "import sys; print(sys.version[[:3]])"`
 python_configdir=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('LIBPL'))))"`
 AC_MSG_RESULT([$python_configdir])
index 8468417f69b5011bcf98214915b1a917ee76489b..908109849e681861243d68ae27b88429dc7702a6 100755 (executable)
--- a/configure
+++ b/configure
@@ -7588,6 +7588,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking Python configuration directory" >&5
 $as_echo_n "checking Python configuration directory... " >&6; }
 python_majorversion=`${PYTHON} -c "import sys; print(sys.version[0])"`
+python_minorversion=`${PYTHON} -c "import sys; print(sys.version[2])"`
 python_version=`${PYTHON} -c "import sys; print(sys.version[:3])"`
 python_configdir=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('LIBPL'))))"`
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $python_configdir" >&5
@@ -7698,6 +7699,9 @@ $as_echo "${python_libspec} ${python_additional_libs}" >&6; }
 
 
 
+  if test "$python_majorversion" -lt 3 -a "$python_minorversion" -lt 4; then
+    as_fn_error $? "Python version $python_version is too old (version 2.4 or later is required)" "$LINENO" 5
+  fi
 fi
 
 if test "$cross_compiling" = yes && test -z "$with_system_tzdata"; then
index 01b618c931ddd44e7d40460d86377ef0e27fb394..9e4fb0fa80a629e8fc63b5af4f11e5dca32b26dd 100644 (file)
@@ -927,6 +927,9 @@ fi
 if test "$with_python" = yes; then
   PGAC_PATH_PYTHON
   PGAC_CHECK_PYTHON_EMBED_SETUP
+  if test "$python_majorversion" -lt 3 -a "$python_minorversion" -lt 4; then
+    AC_MSG_ERROR([Python version $python_version is too old (version 2.4 or later is required)])
+  fi
 fi
 
 if test "$cross_compiling" = yes && test -z "$with_system_tzdata"; then
index b0025c04a81b409e8374f6b1f289899c7d912a75..df49cd5f373a284738d5de90b95babf40472bbc7 100644 (file)
@@ -6,9 +6,7 @@ LANGUAGE plpythonu
 TRANSFORM FOR TYPE hstore
 AS $$
 assert isinstance(val, dict)
-i = list(val.items())
-i.sort()
-plpy.info(i)
+plpy.info(sorted(val.items()))
 return len(val)
 $$;
 SELECT test1('aa=>bb, cc=>NULL'::hstore);
@@ -24,9 +22,7 @@ LANGUAGE plpython2u
 TRANSFORM FOR TYPE hstore
 AS $$
 assert isinstance(val, dict)
-i = list(val.items())
-i.sort()
-plpy.info(i)
+plpy.info(sorted(val.items()))
 return len(val)
 $$;
 SELECT test1n('aa=>bb, cc=>NULL'::hstore);
index d55bedaf50569ee834dffb0bf926155f68479486..911bbd67fede733702ecd2bd405549c69762bbdd 100644 (file)
@@ -7,9 +7,7 @@ LANGUAGE plpythonu
 TRANSFORM FOR TYPE hstore
 AS $$
 assert isinstance(val, dict)
-i = list(val.items())
-i.sort()
-plpy.info(i)
+plpy.info(sorted(val.items()))
 return len(val)
 $$;
 
@@ -22,9 +20,7 @@ LANGUAGE plpython2u
 TRANSFORM FOR TYPE hstore
 AS $$
 assert isinstance(val, dict)
-i = list(val.items())
-i.sort()
-plpy.info(i)
+plpy.info(sorted(val.items()))
 return len(val)
 $$;
 
index 182c801bd5271a3d41ad450a4ba73fc3847968a6..be0931326bc773da681655f9c2ae87fb601e19aa 100644 (file)
@@ -193,11 +193,7 @@ su - postgres
       language, you need a <productname>Python</productname>
       installation with the header files and
       the <application>distutils</application> module.  The minimum
-      required version is <productname>Python</productname> 2.3.
-      (To work with function arguments of type <type>numeric</>, a 2.3.x
-      installation must include the separately-available <filename>cdecimal</>
-      module; note the <application>PL/Python</> regression tests
-      will not pass if that is missing.)
+      required version is <productname>Python</productname> 2.4.
       <productname>Python 3</productname> is supported if it's
       version 3.1 or later; but see
       <![%standalone-include[the <application>PL/Python</> documentation]]>
index 13bd0ab3352dbc7a625373824dd6b47f6eaad99c..1dafd94c7214b521cef988aa8a9f4176413e08ef 100644 (file)
@@ -94,26 +94,22 @@ kwargs = {
     "column_name": _column_name, "datatype_name": _datatype_name,
     "constraint_name": _constraint_name
 }
-# 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)
+# ignore None values
+plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v))
 $$ 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 13, in <module>
-    plpy.error(**dict)
+  PL/Python function "raise_exception", line 9, in <module>
+    plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v))
 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 13, in <module>
-    plpy.error(**dict)
+  PL/Python function "raise_exception", line 9, in <module>
+    plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v))
 PL/Python function "raise_exception"
 SELECT raise_exception(_message => 'message text',
                        _detail => 'detail text',
@@ -128,8 +124,8 @@ ERROR:  plpy.Error: message text
 DETAIL:  detail text
 HINT:  hint text
 CONTEXT:  Traceback (most recent call last):
-  PL/Python function "raise_exception", line 13, in <module>
-    plpy.error(**dict)
+  PL/Python function "raise_exception", line 9, in <module>
+    plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v))
 PL/Python function "raise_exception"
 SELECT raise_exception(_message => 'message text',
                        _hint => 'hint text',
@@ -139,8 +135,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 13, in <module>
-    plpy.error(**dict)
+  PL/Python function "raise_exception", line 9, in <module>
+    plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v))
 PL/Python function "raise_exception"
 DO $$
 DECLARE
index b9c6d64baafd327824ef59e82d8068adbaf747ba..06743e46ed5a5ffdb4ca5103b490152f457dd3ba 100644 (file)
@@ -521,15 +521,9 @@ PLy_input_datum_func2(PLyDatumToOb *arg, MemoryContext arg_mcxt, Oid typeOid, He
 static PyObject *
 PLyBool_FromBool(PLyDatumToOb *arg, Datum d)
 {
-       /*
-        * We would like to use Py_RETURN_TRUE and Py_RETURN_FALSE here for
-        * generating SQL from trigger functions, but those are only supported in
-        * Python >= 2.4, and we support older versions.
-        * http://docs.python.org/api/boolObjects.html
-        */
        if (DatumGetBool(d))
-               return PyBool_FromLong(1);
-       return PyBool_FromLong(0);
+               Py_RETURN_TRUE;
+       Py_RETURN_FALSE;
 }
 
 static PyObject *
index 2612e933876760cbb1f6ce251d7879960ee2c5d7..889293d33c93d7c0dbb3a492226fb70b6b7b2984 100644 (file)
@@ -55,12 +55,8 @@ kwargs = {
     "column_name": _column_name, "datatype_name": _datatype_name,
     "constraint_name": _constraint_name
 }
-# 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)
+# ignore None values
+plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v))
 $$ LANGUAGE plpythonu;
 
 SELECT raise_exception('hello', 'world');