diff options
Diffstat (limited to 'src/pl/plpython/plpy_plpymodule.c')
-rw-r--r-- | src/pl/plpython/plpy_plpymodule.c | 32 |
1 files changed, 8 insertions, 24 deletions
diff --git a/src/pl/plpython/plpy_plpymodule.c b/src/pl/plpython/plpy_plpymodule.c index 907f89d1535..fa08f0dbfb3 100644 --- a/src/pl/plpython/plpy_plpymodule.c +++ b/src/pl/plpython/plpy_plpymodule.c @@ -107,7 +107,6 @@ static PyMethodDef PLy_exc_methods[] = { {NULL, NULL, 0, NULL} }; -#if PY_MAJOR_VERSION >= 3 static PyModuleDef PLy_module = { PyModuleDef_HEAD_INIT, .m_name = "plpy", @@ -139,7 +138,6 @@ PyInit_plpy(void) return m; } -#endif /* PY_MAJOR_VERSION >= 3 */ void PLy_init_plpy(void) @@ -148,10 +146,6 @@ PLy_init_plpy(void) *main_dict, *plpy_mod; -#if PY_MAJOR_VERSION < 3 - PyObject *plpy; -#endif - /* * initialize plpy module */ @@ -160,13 +154,7 @@ PLy_init_plpy(void) PLy_subtransaction_init_type(); PLy_cursor_init_type(); -#if PY_MAJOR_VERSION >= 3 PyModule_Create(&PLy_module); - /* for Python 3 we initialized the exceptions in PyInit_plpy */ -#else - plpy = Py_InitModule("plpy", PLy_methods); - PLy_add_exceptions(plpy); -#endif /* PyDict_SetItemString(plpy, "PlanType", (PyObject *) &PLy_PlanType); */ @@ -189,11 +177,7 @@ PLy_add_exceptions(PyObject *plpy) PyObject *excmod; HASHCTL hash_ctl; -#if PY_MAJOR_VERSION < 3 - excmod = Py_InitModule("spiexceptions", PLy_exc_methods); -#else excmod = PyModule_Create(&PLy_exc_module); -#endif if (excmod == NULL) PLy_elog(ERROR, "could not create the spiexceptions module"); @@ -268,7 +252,7 @@ PLy_generate_spi_exceptions(PyObject *mod, PyObject *base) if (dict == NULL) PLy_elog(ERROR, NULL); - sqlstate = PyString_FromString(unpack_sql_state(exception_map[i].sqlstate)); + sqlstate = PLyUnicode_FromString(unpack_sql_state(exception_map[i].sqlstate)); if (sqlstate == NULL) PLy_elog(ERROR, "could not generate SPI exceptions"); @@ -346,7 +330,7 @@ PLy_quote_literal(PyObject *self, PyObject *args) return NULL; quoted = quote_literal_cstr(str); - ret = PyString_FromString(quoted); + ret = PLyUnicode_FromString(quoted); pfree(quoted); return ret; @@ -363,10 +347,10 @@ PLy_quote_nullable(PyObject *self, PyObject *args) return NULL; if (str == NULL) - return PyString_FromString("NULL"); + return PLyUnicode_FromString("NULL"); quoted = quote_literal_cstr(str); - ret = PyString_FromString(quoted); + ret = PLyUnicode_FromString(quoted); pfree(quoted); return ret; @@ -383,7 +367,7 @@ PLy_quote_ident(PyObject *self, PyObject *args) return NULL; quoted = quote_identifier(str); - ret = PyString_FromString(quoted); + ret = PLyUnicode_FromString(quoted); return ret; } @@ -400,7 +384,7 @@ object_to_string(PyObject *obj) { char *str; - str = pstrdup(PyString_AsString(so)); + str = pstrdup(PLyUnicode_AsString(so)); Py_DECREF(so); return str; @@ -444,7 +428,7 @@ PLy_output(volatile int level, PyObject *self, PyObject *args, PyObject *kw) else so = PyObject_Str(args); - if (so == NULL || ((message = PyString_AsString(so)) == NULL)) + if (so == NULL || ((message = PLyUnicode_AsString(so)) == NULL)) { level = ERROR; message = dgettext(TEXTDOMAIN, "could not parse error message in plpy.elog"); @@ -457,7 +441,7 @@ PLy_output(volatile int level, PyObject *self, PyObject *args, PyObject *kw) { while (PyDict_Next(kw, &pos, &key, &value)) { - char *keyword = PyString_AsString(key); + char *keyword = PLyUnicode_AsString(key); if (strcmp(keyword, "message") == 0) { |