diff options
author | Andres Freund <andres@anarazel.de> | 2022-03-07 18:30:28 -0800 |
---|---|---|
committer | Andres Freund <andres@anarazel.de> | 2022-03-07 18:30:28 -0800 |
commit | 9b7e24a2cb37fb52af13219f625cd719e364a346 (patch) | |
tree | c35fe718f0a8d8723631b5759a47e37bfb6f7fbf /contrib/hstore_plpython/hstore_plpython.c | |
parent | db23464715f4792298c639153dda7bfd9ad9d602 (diff) | |
download | postgresql-9b7e24a2cb37fb52af13219f625cd719e364a346.tar.gz postgresql-9b7e24a2cb37fb52af13219f625cd719e364a346.zip |
plpython: Code cleanup related to removal of Python 2 support.
Since 19252e8ec93 we reject Python 2 during build configuration. Now that the
dust on the buildfarm has settled, remove Python 2 specific code, including
the "Python 2/3 porting layer".
The code to detect conflicts between plpython using Python 2 and 3 is not
removed, in case somebody creates an out-of-tree version adding back support
for Python 2.
Reviewed-By: Peter Eisentraut <peter@eisentraut.org>
Reviewed-By: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/20211031184548.g4sxfe47n2kyi55r@alap3.anarazel.de
Diffstat (limited to 'contrib/hstore_plpython/hstore_plpython.c')
-rw-r--r-- | contrib/hstore_plpython/hstore_plpython.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/contrib/hstore_plpython/hstore_plpython.c b/contrib/hstore_plpython/hstore_plpython.c index 39bad558023..889ece315df 100644 --- a/contrib/hstore_plpython/hstore_plpython.c +++ b/contrib/hstore_plpython/hstore_plpython.c @@ -12,10 +12,8 @@ extern void _PG_init(void); /* Linkage to functions in plpython module */ typedef char *(*PLyObject_AsString_t) (PyObject *plrv); static PLyObject_AsString_t PLyObject_AsString_p; -#if PY_MAJOR_VERSION >= 3 typedef PyObject *(*PLyUnicode_FromStringAndSize_t) (const char *s, Py_ssize_t size); static PLyUnicode_FromStringAndSize_t PLyUnicode_FromStringAndSize_p; -#endif /* Linkage to functions in hstore module */ typedef HStore *(*hstoreUpgrade_t) (Datum orig); @@ -41,12 +39,10 @@ _PG_init(void) PLyObject_AsString_p = (PLyObject_AsString_t) load_external_function("$libdir/" PLPYTHON_LIBNAME, "PLyObject_AsString", true, NULL); -#if PY_MAJOR_VERSION >= 3 AssertVariableIsOfType(&PLyUnicode_FromStringAndSize, PLyUnicode_FromStringAndSize_t); PLyUnicode_FromStringAndSize_p = (PLyUnicode_FromStringAndSize_t) load_external_function("$libdir/" PLPYTHON_LIBNAME, "PLyUnicode_FromStringAndSize", true, NULL); -#endif AssertVariableIsOfType(&hstoreUpgrade, hstoreUpgrade_t); hstoreUpgrade_p = (hstoreUpgrade_t) load_external_function("$libdir/hstore", "hstoreUpgrade", @@ -102,16 +98,16 @@ hstore_to_plpython(PG_FUNCTION_ARGS) { PyObject *key; - key = PyString_FromStringAndSize(HSTORE_KEY(entries, base, i), - HSTORE_KEYLEN(entries, i)); + key = PLyUnicode_FromStringAndSize(HSTORE_KEY(entries, base, i), + HSTORE_KEYLEN(entries, i)); if (HSTORE_VALISNULL(entries, i)) PyDict_SetItem(dict, key, Py_None); else { PyObject *value; - value = PyString_FromStringAndSize(HSTORE_VAL(entries, base, i), - HSTORE_VALLEN(entries, i)); + value = PLyUnicode_FromStringAndSize(HSTORE_VAL(entries, base, i), + HSTORE_VALLEN(entries, i)); PyDict_SetItem(dict, key, value); Py_XDECREF(value); } |