diff --git a/psycopg/connection_type.c b/psycopg/connection_type.c index d86040b0..1f54ccfe 100644 --- a/psycopg/connection_type.c +++ b/psycopg/connection_type.c @@ -442,9 +442,6 @@ exit: } -#ifdef PSYCOPG_EXTENSIONS - - /* parse a python object into one of the possible isolation level values */ extern const IsolationLevel conn_isolevels[]; @@ -860,8 +857,6 @@ psyco_conn_poll(connectionObject *self) } -/* extension: fileno - return the file descriptor of the connection */ - #define psyco_conn_fileno_doc \ "fileno() -> int -- Return file descriptor associated to database connection." @@ -878,8 +873,6 @@ psyco_conn_fileno(connectionObject *self) } -/* extension: isexecuting - check for asynchronous operations */ - #define psyco_conn_isexecuting_doc \ "isexecuting() -> bool -- Return True if the connection is " \ "executing an asynchronous operation." @@ -911,8 +904,6 @@ psyco_conn_isexecuting(connectionObject *self) } -/* extension: cancel - cancel the current operation */ - #define psyco_conn_cancel_doc \ "cancel() -- cancel the current operation" @@ -941,8 +932,6 @@ psyco_conn_cancel(connectionObject *self) Py_RETURN_NONE; } -#endif /* PSYCOPG_EXTENSIONS */ - /** the connection object **/ @@ -974,7 +963,6 @@ static struct PyMethodDef connectionObject_methods[] = { METH_NOARGS, psyco_conn_enter_doc}, {"__exit__", (PyCFunction)psyco_conn_exit, METH_VARARGS, psyco_conn_exit_doc}, -#ifdef PSYCOPG_EXTENSIONS {"set_session", (PyCFunction)psyco_conn_set_session, METH_VARARGS|METH_KEYWORDS, psyco_conn_set_session_doc}, {"set_isolation_level", (PyCFunction)psyco_conn_set_isolation_level, @@ -999,14 +987,12 @@ static struct PyMethodDef connectionObject_methods[] = { METH_NOARGS, psyco_conn_isexecuting_doc}, {"cancel", (PyCFunction)psyco_conn_cancel, METH_NOARGS, psyco_conn_cancel_doc}, -#endif {NULL} }; /* object member list */ static struct PyMemberDef connectionObject_members[] = { -#ifdef PSYCOPG_EXTENSIONS {"closed", T_LONG, offsetof(connectionObject, closed), READONLY, "True if the connection is closed."}, {"encoding", T_STRING, offsetof(connectionObject, encoding), READONLY, @@ -1032,7 +1018,6 @@ static struct PyMemberDef connectionObject_members[] = { {"server_version", T_INT, offsetof(connectionObject, server_version), READONLY, "Server version."}, -#endif {NULL} }; @@ -1040,7 +1025,6 @@ static struct PyMemberDef connectionObject_members[] = { { #exc, psyco_conn_get_exception, NULL, exc ## _doc, &exc } static struct PyGetSetDef connectionObject_getsets[] = { - /* DBAPI-2.0 extensions (exception objects) */ EXCEPTION_GETTER(Error), EXCEPTION_GETTER(Warning), EXCEPTION_GETTER(InterfaceError), @@ -1051,7 +1035,6 @@ static struct PyGetSetDef connectionObject_getsets[] = { EXCEPTION_GETTER(IntegrityError), EXCEPTION_GETTER(DataError), EXCEPTION_GETTER(NotSupportedError), -#ifdef PSYCOPG_EXTENSIONS { "autocommit", (getter)psyco_conn_autocommit_get, (setter)psyco_conn_autocommit_set, @@ -1060,7 +1043,6 @@ static struct PyGetSetDef connectionObject_getsets[] = { (getter)psyco_conn_isolation_level_get, (setter)NULL, "The current isolation level." }, -#endif {NULL} }; #undef EXCEPTION_GETTER diff --git a/psycopg/cursor_type.c b/psycopg/cursor_type.c index 40dbaef0..784c0a1e 100644 --- a/psycopg/cursor_type.c +++ b/psycopg/cursor_type.c @@ -559,7 +559,6 @@ psyco_curs_executemany(cursorObject *self, PyObject *args, PyObject *kwargs) } -#ifdef PSYCOPG_EXTENSIONS #define psyco_curs_mogrify_doc \ "mogrify(query, vars=None) -> str -- Return query after vars binding." @@ -622,7 +621,6 @@ psyco_curs_mogrify(cursorObject *self, PyObject *args, PyObject *kwargs) return _psyco_curs_mogrify(self, operation, vars); } -#endif /* cast method - convert an oid/string into a Python object */ @@ -1222,8 +1220,6 @@ exit: } -#ifdef PSYCOPG_EXTENSIONS - /* Return a newly allocated buffer containing the list of columns to be * copied. On error return NULL and set an exception. */ @@ -1669,8 +1665,6 @@ psyco_curs_scrollable_set(cursorObject *self, PyObject *pyvalue) return 0; } -#endif - /** the cursor object **/ @@ -1738,7 +1732,6 @@ static struct PyMethodDef cursorObject_methods[] = { {"__exit__", (PyCFunction)psyco_curs_exit, METH_VARARGS, psyco_curs_exit_doc}, /* psycopg extensions */ -#ifdef PSYCOPG_EXTENSIONS {"cast", (PyCFunction)psyco_curs_cast, METH_VARARGS, psyco_curs_cast_doc}, {"mogrify", (PyCFunction)psyco_curs_mogrify, @@ -1749,7 +1742,6 @@ static struct PyMethodDef cursorObject_methods[] = { METH_VARARGS|METH_KEYWORDS, psyco_curs_copy_to_doc}, {"copy_expert", (PyCFunction)psyco_curs_copy_expert, METH_VARARGS|METH_KEYWORDS, psyco_curs_copy_expert_doc}, -#endif {NULL} }; @@ -1775,7 +1767,6 @@ static struct PyMemberDef cursorObject_members[] = { "The current row position."}, {"connection", T_OBJECT, OFFSETOF(conn), READONLY, "The connection where the cursor comes from."}, -#ifdef PSYCOPG_EXTENSIONS {"name", T_STRING, OFFSETOF(name), READONLY}, {"statusmessage", T_OBJECT, OFFSETOF(pgstatus), READONLY, "The return message of the last command."}, @@ -1786,13 +1777,11 @@ static struct PyMemberDef cursorObject_members[] = { {"typecaster", T_OBJECT, OFFSETOF(caster), READONLY}, {"string_types", T_OBJECT, OFFSETOF(string_types), 0}, {"binary_types", T_OBJECT, OFFSETOF(binary_types), 0}, -#endif {NULL} }; /* object calculated member list */ static struct PyGetSetDef cursorObject_getsets[] = { -#ifdef PSYCOPG_EXTENSIONS { "closed", (getter)psyco_curs_get_closed, NULL, psyco_curs_closed_doc, NULL }, { "withhold", @@ -1803,7 +1792,6 @@ static struct PyGetSetDef cursorObject_getsets[] = { (getter)psyco_curs_scrollable_get, (setter)psyco_curs_scrollable_set, psyco_curs_scrollable_doc, NULL }, -#endif {NULL} }; diff --git a/psycopg/green.c b/psycopg/green.c index e7604076..ab37b8be 100644 --- a/psycopg/green.c +++ b/psycopg/green.c @@ -80,11 +80,7 @@ psyco_get_wait_callback(PyObject *self, PyObject *obj) int psyco_green() { -#ifdef PSYCOPG_EXTENSIONS return (NULL != wait_callback); -#else - return 0; -#endif } /* Return the wait callback if available. diff --git a/psycopg/lobject_int.c b/psycopg/lobject_int.c index 43f2b179..21b1e189 100644 --- a/psycopg/lobject_int.c +++ b/psycopg/lobject_int.c @@ -32,8 +32,6 @@ #include -#ifdef PSYCOPG_EXTENSIONS - static void collect_error(connectionObject *conn, char **error) { @@ -490,6 +488,3 @@ lobject_truncate(lobjectObject *self, size_t len) } #endif /* PG_VERSION_HEX >= 0x080300 */ - -#endif - diff --git a/psycopg/lobject_type.c b/psycopg/lobject_type.c index 63511149..e62ddc27 100644 --- a/psycopg/lobject_type.c +++ b/psycopg/lobject_type.c @@ -35,8 +35,6 @@ #include -#ifdef PSYCOPG_EXTENSIONS - /** public methods **/ /* close method - close the lobject */ @@ -272,8 +270,6 @@ psyco_lobj_truncate(lobjectObject *self, PyObject *args) Py_RETURN_NONE; } -#endif /* PG_VERSION_HEX >= 0x080300 */ - /** the lobject object **/ diff --git a/psycopg/pqpath.c b/psycopg/pqpath.c index 3512f639..ae6a18bb 100644 --- a/psycopg/pqpath.c +++ b/psycopg/pqpath.c @@ -113,11 +113,7 @@ exception_from_sqlstate(const char *sqlstate) case '4': switch (sqlstate[1]) { case '0': /* Class 40 - Transaction Rollback */ -#ifdef PSYCOPG_EXTENSIONS return TransactionRollbackError; -#else - return OperationalError; -#endif case '2': /* Class 42 - Syntax Error or Access Rule Violation */ case '4': /* Class 44 - WITH CHECK OPTION Violation */ return ProgrammingError; @@ -129,11 +125,9 @@ exception_from_sqlstate(const char *sqlstate) Class 55 - Object Not In Prerequisite State Class 57 - Operator Intervention Class 58 - System Error (errors external to PostgreSQL itself) */ -#ifdef PSYCOPG_EXTENSIONS if (!strcmp(sqlstate, "57014")) return QueryCanceledError; else -#endif return OperationalError; case 'F': /* Class F0 - Configuration File Error */ return InternalError; diff --git a/psycopg/psycopg.h b/psycopg/psycopg.h index 2a90c255..eb406fd2 100644 --- a/psycopg/psycopg.h +++ b/psycopg/psycopg.h @@ -63,9 +63,7 @@ HIDDEN psyco_errors_set_RETURN psyco_errors_set psyco_errors_set_PROTO; extern HIDDEN PyObject *Error, *Warning, *InterfaceError, *DatabaseError, *InternalError, *OperationalError, *ProgrammingError, *IntegrityError, *DataError, *NotSupportedError; -#ifdef PSYCOPG_EXTENSIONS extern HIDDEN PyObject *QueryCanceledError, *TransactionRollbackError; -#endif /* python versions and compatibility stuff */ #ifndef PyMODINIT_FUNC @@ -164,13 +162,11 @@ STEALS(1) HIDDEN PyObject * psycopg_ensure_text(PyObject *obj); #define NotSupportedError_doc \ "A method or database API was used which is not supported by the database." -#ifdef PSYCOPG_EXTENSIONS #define QueryCanceledError_doc \ "Error related to SQL query cancellation." #define TransactionRollbackError_doc \ "Error causing transaction rollback (deadlocks, serialization failures, etc)." -#endif #ifdef __cplusplus } diff --git a/psycopg/psycopgmodule.c b/psycopg/psycopgmodule.c index 04c0ed7c..3ccd2828 100644 --- a/psycopg/psycopgmodule.c +++ b/psycopg/psycopgmodule.c @@ -398,9 +398,7 @@ exit: PyObject *Error, *Warning, *InterfaceError, *DatabaseError, *InternalError, *OperationalError, *ProgrammingError, *IntegrityError, *DataError, *NotSupportedError; -#ifdef PSYCOPG_EXTENSIONS PyObject *QueryCanceledError, *TransactionRollbackError; -#endif /* mapping between exception names and their PyObject */ static struct { @@ -423,13 +421,11 @@ static struct { { "psycopg2.DataError", &DataError, &DatabaseError, DataError_doc }, { "psycopg2.NotSupportedError", &NotSupportedError, &DatabaseError, NotSupportedError_doc }, -#ifdef PSYCOPG_EXTENSIONS { "psycopg2.extensions.QueryCanceledError", &QueryCanceledError, &OperationalError, QueryCanceledError_doc }, { "psycopg2.extensions.TransactionRollbackError", &TransactionRollbackError, &OperationalError, TransactionRollbackError_doc }, -#endif {NULL} /* Sentinel */ }; @@ -712,12 +708,10 @@ static PyMethodDef psycopgMethods[] = { METH_VARARGS, psyco_IntervalFromMx_doc}, #endif -#ifdef PSYCOPG_EXTENSIONS {"set_wait_callback", (PyCFunction)psyco_set_wait_callback, METH_O, psyco_set_wait_callback_doc}, {"get_wait_callback", (PyCFunction)psyco_get_wait_callback, METH_NOARGS, psyco_get_wait_callback_doc}, -#endif {NULL, NULL, 0, NULL} /* Sentinel */ }; @@ -806,10 +800,8 @@ INIT_MODULE(_psycopg)(void) Py_TYPE(&diagnosticsType) = &PyType_Type; if (PyType_Ready(&diagnosticsType) == -1) goto exit; -#ifdef PSYCOPG_EXTENSIONS Py_TYPE(&lobjectType) = &PyType_Type; if (PyType_Ready(&lobjectType) == -1) goto exit; -#endif /* import mx.DateTime module, if necessary */ #ifdef HAVE_MXDATETIME @@ -904,9 +896,7 @@ INIT_MODULE(_psycopg)(void) PyModule_AddObject(module, "Float", (PyObject*)&pfloatType); PyModule_AddObject(module, "List", (PyObject*)&listType); PyModule_AddObject(module, "QuotedString", (PyObject*)&qstringType); -#ifdef PSYCOPG_EXTENSIONS PyModule_AddObject(module, "lobject", (PyObject*)&lobjectType); -#endif /* encodings dictionary in module dictionary */ PyModule_AddObject(module, "encodings", psycoEncodings); diff --git a/setup.cfg b/setup.cfg index 7f6e84e5..83962bfb 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,7 +1,6 @@ [build_ext] -define=PSYCOPG_EXTENSIONS,PSYCOPG_NEW_BOOLEAN,HAVE_PQFREEMEM +define=PSYCOPG_NEW_BOOLEAN,HAVE_PQFREEMEM -# PSYCOPG_EXTENSIONS enables extensions to PEP-249 (you really want this) # PSYCOPG_DISPLAY_SIZE enable display size calculation (a little slower) # HAVE_PQFREEMEM should be defined on PostgreSQL >= 7.4 # PSYCOPG_DEBUG can be added to enable verbose debug information diff --git a/setup.py b/setup.py index 92ac1038..f08a4f3f 100644 --- a/setup.py +++ b/setup.py @@ -511,10 +511,7 @@ you probably need to install its companion -dev or -devel package.""" # generate a nice version string to avoid confusion when users report bugs version_flags.append('pq3') # no more a choice - -for have in parser.get('build_ext', 'define').split(','): - if have == 'PSYCOPG_EXTENSIONS': - version_flags.append('ext') +version_flags.append('ext') # no more a choice if version_flags: PSYCOPG_VERSION_EX = PSYCOPG_VERSION + " (%s)" % ' '.join(version_flags)