I would like to propose that we drop support for Python 2.3.  Reasons:

- Python 3.6 was released in December.  The list of versions we need to
manage is growing.

- Older Python versions are increasingly hard to build locally for testing.

- It's unlikely that Python 2.3 is still used in practice.  Python 2.4
is in RHEL 5, which is the typically the oldest mainstream OS we look at.

- We could remove some cruft from the code.

We do have buildfarm coverage on prairiedog.  However, that runs a >10
year old operating system, so I think it is not representing real usage.

Patch attached.

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
From 94592edd240680224e5a971e8be7a5127f193d0c Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pete...@gmx.net>
Date: Tue, 16 Aug 2016 12:00:00 -0400
Subject: [PATCH] Drop support for Python 2.3

---
 .../hstore_plpython/expected/hstore_plpython.out   |  8 ++------
 contrib/hstore_plpython/sql/hstore_plpython.sql    |  8 ++------
 doc/src/sgml/installation.sgml                     |  6 +-----
 src/pl/plpython/expected/plpython_ereport.out      | 24 +++++++++-------------
 src/pl/plpython/plpy_typeio.c                      | 10 ++-------
 src/pl/plpython/sql/plpython_ereport.sql           |  8 ++------
 6 files changed, 19 insertions(+), 45 deletions(-)

diff --git a/contrib/hstore_plpython/expected/hstore_plpython.out b/contrib/hstore_plpython/expected/hstore_plpython.out
index b0025c04a8..df49cd5f37 100644
--- a/contrib/hstore_plpython/expected/hstore_plpython.out
+++ b/contrib/hstore_plpython/expected/hstore_plpython.out
@@ -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);
diff --git a/contrib/hstore_plpython/sql/hstore_plpython.sql b/contrib/hstore_plpython/sql/hstore_plpython.sql
index d55bedaf50..911bbd67fe 100644
--- a/contrib/hstore_plpython/sql/hstore_plpython.sql
+++ b/contrib/hstore_plpython/sql/hstore_plpython.sql
@@ -7,9 +7,7 @@ CREATE FUNCTION test1(val hstore) RETURNS int
 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 @@ CREATE FUNCTION test1n(val hstore) RETURNS int
 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)
 $$;
 
diff --git a/doc/src/sgml/installation.sgml b/doc/src/sgml/installation.sgml
index 4431ed75a9..231d9dea4a 100644
--- a/doc/src/sgml/installation.sgml
+++ b/doc/src/sgml/installation.sgml
@@ -193,11 +193,7 @@ <title>Requirements</title>
       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]]>
diff --git a/src/pl/plpython/expected/plpython_ereport.out b/src/pl/plpython/expected/plpython_ereport.out
index 13bd0ab335..1dafd94c72 100644
--- a/src/pl/plpython/expected/plpython_ereport.out
+++ b/src/pl/plpython/expected/plpython_ereport.out
@@ -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
diff --git a/src/pl/plpython/plpy_typeio.c b/src/pl/plpython/plpy_typeio.c
index b9c6d64baa..06743e46ed 100644
--- a/src/pl/plpython/plpy_typeio.c
+++ b/src/pl/plpython/plpy_typeio.c
@@ -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 *
diff --git a/src/pl/plpython/sql/plpython_ereport.sql b/src/pl/plpython/sql/plpython_ereport.sql
index 2612e93387..889293d33c 100644
--- a/src/pl/plpython/sql/plpython_ereport.sql
+++ b/src/pl/plpython/sql/plpython_ereport.sql
@@ -55,12 +55,8 @@ CREATE OR REPLACE FUNCTION raise_exception(_message text, _detail text DEFAULT N
     "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');
-- 
2.11.1

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to