I have found some dying code in PL/Python.

The simple slicing API (sq_slice, sq_ass_slice) has been deprecated
since Python 2.0 and has been removed altogether in Python 3, so we can
remove those functions from the PLyResult class.  Instead, the non-slice
mapping functions mp_subscript and mp_ass_subscript can take slice
objects as an index.  Since we just pass the index through to the
underlying list object, we already support that.  Test coverage was
already in place.

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
From 2676469f45fbc2a442a251d2b0ef8184b5cd5e2b Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pete...@gmx.net>
Date: Wed, 29 Aug 2018 11:10:17 +0200
Subject: [PATCH] PL/Python: Remove use of simple slicing API

The simple slicing API (sq_slice, sq_ass_slice) has been deprecated
since Python 2.0 and has been removed altogether in Python 3, so remove
those functions from the PLyResult class.  Instead, the non-slice
mapping functions mp_subscript and mp_ass_subscript can take slice
objects as an index.  Since we just pass the index through to the
underlying list object, we already support that.  Test coverage was
already in place.
---
 src/pl/plpython/plpy_resultobject.c | 24 ++----------------------
 1 file changed, 2 insertions(+), 22 deletions(-)

diff --git a/src/pl/plpython/plpy_resultobject.c 
b/src/pl/plpython/plpy_resultobject.c
index ca70e25689..4064f6a7a2 100644
--- a/src/pl/plpython/plpy_resultobject.c
+++ b/src/pl/plpython/plpy_resultobject.c
@@ -20,8 +20,6 @@ static PyObject *PLy_result_nrows(PyObject *self, PyObject 
*args);
 static PyObject *PLy_result_status(PyObject *self, PyObject *args);
 static Py_ssize_t PLy_result_length(PyObject *arg);
 static PyObject *PLy_result_item(PyObject *arg, Py_ssize_t idx);
-static PyObject *PLy_result_slice(PyObject *arg, Py_ssize_t lidx, Py_ssize_t 
hidx);
-static int     PLy_result_ass_slice(PyObject *arg, Py_ssize_t lidx, Py_ssize_t 
hidx, PyObject *slice);
 static PyObject *PLy_result_str(PyObject *arg);
 static PyObject *PLy_result_subscript(PyObject *arg, PyObject *item);
 static int     PLy_result_ass_subscript(PyObject *self, PyObject *item, 
PyObject *value);
@@ -35,9 +33,9 @@ static PySequenceMethods PLy_result_as_sequence = {
        NULL,                                           /* sq_concat */
        NULL,                                           /* sq_repeat */
        PLy_result_item,                        /* sq_item */
-       PLy_result_slice,                       /* sq_slice */
+       NULL,                                           /* sq_slice */
        NULL,                                           /* sq_ass_item */
-       PLy_result_ass_slice,           /* sq_ass_slice */
+       NULL,                                           /* sq_ass_slice */
 };
 
 static PyMappingMethods PLy_result_as_mapping = {
@@ -254,24 +252,6 @@ PLy_result_item(PyObject *arg, Py_ssize_t idx)
        return rv;
 }
 
-static PyObject *
-PLy_result_slice(PyObject *arg, Py_ssize_t lidx, Py_ssize_t hidx)
-{
-       PLyResultObject *ob = (PLyResultObject *) arg;
-
-       return PyList_GetSlice(ob->rows, lidx, hidx);
-}
-
-static int
-PLy_result_ass_slice(PyObject *arg, Py_ssize_t lidx, Py_ssize_t hidx, PyObject 
*slice)
-{
-       int                     rv;
-       PLyResultObject *ob = (PLyResultObject *) arg;
-
-       rv = PyList_SetSlice(ob->rows, lidx, hidx, slice);
-       return rv;
-}
-
 static PyObject *
 PLy_result_str(PyObject *arg)
 {
-- 
2.18.0

Reply via email to