summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>2019-01-21 19:10:30 +0000
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>2019-01-21 20:18:53 +0000
commit8f17ccf784abe5ae79468c8f72e9a799551f9fc5 (patch)
treecea61049aea6143587b7c10673c9c6f18232fc88
parent7b2e8f0aa4be137bfdaee68b2ebef135901fa080 (diff)
downloadpsycopg2-8f17ccf784abe5ae79468c8f72e9a799551f9fc5.tar.gz
Dropped C API interface
I guess it was unused as it only contained two init functions. The Capsule should do things better now I guess.
-rw-r--r--psycopg/psycopg.h52
-rw-r--r--psycopg/psycopgmodule.c36
2 files changed, 4 insertions, 84 deletions
diff --git a/psycopg/psycopg.h b/psycopg/psycopg.h
index 7b623fa..c7591c9 100644
--- a/psycopg/psycopg.h
+++ b/psycopg/psycopg.h
@@ -47,64 +47,12 @@ extern "C" {
#define THREADSAFETY 2
#define PARAMSTYLE "pyformat"
-/* C API functions */
-#define psyco_errors_fill_NUM 0
-#define psyco_errors_fill_RETURN void
-#define psyco_errors_fill_PROTO (PyObject *dict)
-#define psyco_errors_set_NUM 1
-#define psyco_errors_set_RETURN void
-#define psyco_errors_set_PROTO (PyObject *type)
-
-/* Total number of C API pointers */
-#define PSYCOPG_API_pointers 2
-
-#ifdef PSYCOPG_MODULE
-
- /** This section is used when compiling psycopgmodule.c & co. **/
-HIDDEN psyco_errors_fill_RETURN psyco_errors_fill psyco_errors_fill_PROTO;
-HIDDEN psyco_errors_set_RETURN psyco_errors_set psyco_errors_set_PROTO;
-
/* global exceptions */
extern HIDDEN PyObject *Error, *Warning, *InterfaceError, *DatabaseError,
*InternalError, *OperationalError, *ProgrammingError,
*IntegrityError, *DataError, *NotSupportedError;
extern HIDDEN PyObject *QueryCanceledError, *TransactionRollbackError;
-/* python versions and compatibility stuff */
-#ifndef PyMODINIT_FUNC
-#define PyMODINIT_FUNC void
-#endif
-
-#else
- /** This section is used in modules that use psycopg's C API **/
-
-static void **PSYCOPG_API;
-
-#define psyco_errors_fill \
- (*(psyco_errors_fill_RETURN (*)psyco_errors_fill_PROTO) \
- PSYCOPG_API[psyco_errors_fill_NUM])
-#define psyco_errors_set \
- (*(psyco_errors_set_RETURN (*)psyco_errors_set_PROTO) \
- PSYCOPG_API[psyco_errors_set_NUM])
-
-/* Return -1 and set exception on error, 0 on success. */
-static int
-import_psycopg(void)
-{
- PyObject *module = PyImport_ImportModule("psycopg");
-
- if (module != NULL) {
- PyObject *c_api_object = PyObject_GetAttrString(module, "_C_API");
- if (c_api_object == NULL) return -1;
- if (PyCObject_Check(c_api_object))
- PSYCOPG_API = (void **)PyCObject_AsVoidPtr(c_api_object);
- Py_DECREF(c_api_object);
- }
- return 0;
-}
-
-#endif
-
/* postgresql<->python encoding map */
extern HIDDEN PyObject *psycoEncodings;
diff --git a/psycopg/psycopgmodule.c b/psycopg/psycopgmodule.c
index 4136fce..565adeb 100644
--- a/psycopg/psycopgmodule.c
+++ b/psycopg/psycopgmodule.c
@@ -608,9 +608,7 @@ exit:
return rv;
}
-/* psyco_errors_init, psyco_errors_fill (callable from C)
-
- Initialize the module's exceptions and after that a dictionary with a full
+/* Initialize the module's exceptions and after that a dictionary with a full
set of exceptions. */
PyObject *Error, *Warning, *InterfaceError, *DatabaseError,
@@ -710,23 +708,6 @@ psyco_errors_fill(PyObject *dict)
}
}
-void
-psyco_errors_set(PyObject *type)
-{
- int i;
- char *name;
-
- for (i = 0; exctable[i].name; i++) {
- if (NULL == exctable[i].exc) { continue; }
-
- /* the name is the part after the last dot */
- name = strrchr(exctable[i].name, '.');
- name = name ? name + 1 : exctable[i].name;
-
- PyObject_SetAttrString(type, name, *exctable[i].exc);
- }
-}
-
RAISES_NEG
static int
add_module_constants(PyObject *module)
@@ -892,14 +873,12 @@ static struct PyModuleDef psycopgmodule = {
};
#endif
+#ifndef PyMODINIT_FUNC /* declarations for DLL import/export */
+#define PyMODINIT_FUNC void
+#endif
PyMODINIT_FUNC
INIT_MODULE(_psycopg)(void)
{
-#if PY_VERSION_HEX < 0x03020000
- static void *PSYCOPG_API[PSYCOPG_API_pointers];
- PyObject *c_api_object;
-#endif
-
PyObject *module = NULL, *dict;
#ifdef PSYCOPG_DEBUG
@@ -965,13 +944,6 @@ INIT_MODULE(_psycopg)(void)
#endif
if (!module) { goto exit; }
- /* Create a CObject containing the API pointer array's address */
-#if PY_VERSION_HEX < 0x03020000
- c_api_object = PyCObject_FromVoidPtr((void *)PSYCOPG_API, NULL);
- if (c_api_object != NULL)
- PyModule_AddObject(module, "_C_API", c_api_object);
-#endif
-
/* other mixed initializations of module-level variables */
if (!(psycoEncodings = PyDict_New())) { goto exit; }
if (0 != psyco_encodings_fill(psycoEncodings)) { goto exit; }