diff options
author | Jon Dufresne <jon.dufresne@gmail.com> | 2019-03-16 07:21:31 -0700 |
---|---|---|
committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2019-03-16 16:36:49 +0000 |
commit | 432fdd7d32eaa4df94a16fa0bc84abc9a7d95989 (patch) | |
tree | 5e3f75a05252d8cf8acbb0ab0bf987cd35c7fb5e /psycopg | |
parent | 8685120485cdc4516f0c46ba2c4968e8bc6b80a2 (diff) | |
download | psycopg2-432fdd7d32eaa4df94a16fa0bc84abc9a7d95989.tar.gz |
Removed support for mxDateTime as the default date and time adapter
The use_pydatetime configuration option has been removed. Now, always
default to Python's builtin datetime. mxDatetime support continues to be
available as an alternative to Python's builtin datetime.
Diffstat (limited to 'psycopg')
-rw-r--r-- | psycopg/adapter_datetime.c | 4 | ||||
-rw-r--r-- | psycopg/adapter_datetime.h | 5 | ||||
-rw-r--r-- | psycopg/adapter_mxdatetime.c | 125 | ||||
-rw-r--r-- | psycopg/adapter_mxdatetime.h | 29 | ||||
-rw-r--r-- | psycopg/psycopgmodule.c | 7 | ||||
-rw-r--r-- | psycopg/typecast_datetime.c | 2 | ||||
-rw-r--r-- | psycopg/typecast_mxdatetime.c | 10 |
7 files changed, 0 insertions, 182 deletions
diff --git a/psycopg/adapter_datetime.c b/psycopg/adapter_datetime.c index e76dc26..5620fc7 100644 --- a/psycopg/adapter_datetime.c +++ b/psycopg/adapter_datetime.c @@ -265,8 +265,6 @@ PyTypeObject pydatetimeType = { /** module-level functions **/ -#ifdef PSYCOPG_DEFAULT_PYDATETIME - PyObject * psyco_Date(PyObject *self, PyObject *args) { @@ -458,8 +456,6 @@ exit: return res; } -#endif - PyObject * psyco_DateFromPy(PyObject *self, PyObject *args) { diff --git a/psycopg/adapter_datetime.h b/psycopg/adapter_datetime.h index 47b33ea..eb0fc92 100644 --- a/psycopg/adapter_datetime.h +++ b/psycopg/adapter_datetime.h @@ -47,9 +47,6 @@ typedef struct { RAISES_NEG HIDDEN int psyco_adapter_datetime_init(void); -/* functions exported to psycopgmodule.c */ -#ifdef PSYCOPG_DEFAULT_PYDATETIME - HIDDEN PyObject *psyco_Date(PyObject *module, PyObject *args); #define psyco_Date_doc \ "Date(year, month, day) -> new date\n\n" \ @@ -86,8 +83,6 @@ HIDDEN PyObject *psyco_TimestampFromTicks(PyObject *module, PyObject *args); "Ticks are the number of seconds since the epoch; see the documentation " \ "of the standard Python time module for details)." -#endif /* PSYCOPG_DEFAULT_PYDATETIME */ - HIDDEN PyObject *psyco_DateFromPy(PyObject *module, PyObject *args); #define psyco_DateFromPy_doc \ "DateFromPy(datetime.date) -> new wrapper" diff --git a/psycopg/adapter_mxdatetime.c b/psycopg/adapter_mxdatetime.c index 9f17da1..cca8790 100644 --- a/psycopg/adapter_mxdatetime.c +++ b/psycopg/adapter_mxdatetime.c @@ -254,131 +254,6 @@ PyTypeObject mxdatetimeType = { /** module-level functions **/ -#ifdef PSYCOPG_DEFAULT_MXDATETIME - -PyObject * -psyco_Date(PyObject *self, PyObject *args) -{ - PyObject *res, *mx; - int year, month, day; - - if (!PyArg_ParseTuple(args, "iii", &year, &month, &day)) - return NULL; - - mx = mxDateTime.DateTime_FromDateAndTime(year, month, day, 0, 0, 0.0); - if (mx == NULL) return NULL; - - res = PyObject_CallFunction((PyObject *)&mxdatetimeType, "Oi", mx, - PSYCO_MXDATETIME_DATE); - Py_DECREF(mx); - return res; -} - -PyObject * -psyco_Time(PyObject *self, PyObject *args) -{ - PyObject *res, *mx; - int hours, minutes=0; - double seconds=0.0; - - if (!PyArg_ParseTuple(args, "iid", &hours, &minutes, &seconds)) - return NULL; - - mx = mxDateTime.DateTimeDelta_FromTime(hours, minutes, seconds); - if (mx == NULL) return NULL; - - res = PyObject_CallFunction((PyObject *)&mxdatetimeType, "Oi", mx, - PSYCO_MXDATETIME_TIME); - Py_DECREF(mx); - return res; -} - -PyObject * -psyco_Timestamp(PyObject *self, PyObject *args) -{ - PyObject *res, *mx; - int year, month, day; - int hour=0, minute=0; /* default to midnight */ - double second=0.0; - - if (!PyArg_ParseTuple(args, "lii|iid", &year, &month, &day, - &hour, &minute, &second)) - return NULL; - - mx = mxDateTime.DateTime_FromDateAndTime(year, month, day, - hour, minute, second); - if (mx == NULL) return NULL; - - res = PyObject_CallFunction((PyObject *)&mxdatetimeType, "Oi", mx, - PSYCO_MXDATETIME_TIMESTAMP); - Py_DECREF(mx); - return res; -} - -PyObject * -psyco_DateFromTicks(PyObject *self, PyObject *args) -{ - PyObject *res, *mx; - double ticks; - - if (!PyArg_ParseTuple(args,"d", &ticks)) - return NULL; - - if (!(mx = mxDateTime.DateTime_FromTicks(ticks))) - return NULL; - - res = PyObject_CallFunction((PyObject *)&mxdatetimeType, "Oi", mx, - PSYCO_MXDATETIME_DATE); - Py_DECREF(mx); - return res; -} - -PyObject * -psyco_TimeFromTicks(PyObject *self, PyObject *args) -{ - PyObject *res, *mx, *dt; - double ticks; - - if (!PyArg_ParseTuple(args,"d", &ticks)) - return NULL; - - if (!(dt = mxDateTime.DateTime_FromTicks(ticks))) - return NULL; - - if (!(mx = mxDateTime.DateTimeDelta_FromDaysAndSeconds( - 0, ((mxDateTimeObject*)dt)->abstime))) - { - Py_DECREF(dt); - return NULL; - } - - Py_DECREF(dt); - res = PyObject_CallFunction((PyObject *)&mxdatetimeType, "Oi", mx, - PSYCO_MXDATETIME_TIME); - Py_DECREF(mx); - return res; -} - -PyObject * -psyco_TimestampFromTicks(PyObject *self, PyObject *args) -{ - PyObject *mx, *res; - double ticks; - - if (!PyArg_ParseTuple(args, "d", &ticks)) - return NULL; - - if (!(mx = mxDateTime.DateTime_FromTicks(ticks))) - return NULL; - - res = PyObject_CallFunction((PyObject *)&mxdatetimeType, "Oi", mx, - PSYCO_MXDATETIME_TIMESTAMP); - Py_DECREF(mx); - return res; -} - -#endif - PyObject * psyco_DateFromMx(PyObject *self, PyObject *args) { diff --git a/psycopg/adapter_mxdatetime.h b/psycopg/adapter_mxdatetime.h index 1b5d2a6..4b1df68 100644 --- a/psycopg/adapter_mxdatetime.h +++ b/psycopg/adapter_mxdatetime.h @@ -44,35 +44,6 @@ typedef struct { } mxdatetimeObject; -/* functions exported to psycopgmodule.c */ -#ifdef PSYCOPG_DEFAULT_MXDATETIME - -HIDDEN PyObject *psyco_Date(PyObject *module, PyObject *args); -#define psyco_Date_doc \ - "Date(year, month, day) -> new date" - -HIDDEN PyObject *psyco_Time(PyObject *module, PyObject *args); -#define psyco_Time_doc \ - "Time(hour, minutes, seconds) -> new time" - -HIDDEN PyObject *psyco_Timestamp(PyObject *module, PyObject *args); -#define psyco_Timestamp_doc \ - "Time(year, month, day, hour, minutes, seconds) -> new timestamp" - -HIDDEN PyObject *psyco_DateFromTicks(PyObject *module, PyObject *args); -#define psyco_DateFromTicks_doc \ - "DateFromTicks(ticks) -> new date" - -HIDDEN PyObject *psyco_TimeFromTicks(PyObject *module, PyObject *args); -#define psyco_TimeFromTicks_doc \ - "TimeFromTicks(ticks) -> new time" - -HIDDEN PyObject *psyco_TimestampFromTicks(PyObject *module, PyObject *args); -#define psyco_TimestampFromTicks_doc \ - "TimestampFromTicks(ticks) -> new timestamp" - -#endif /* PSYCOPG_DEFAULT_MXDATETIME */ - HIDDEN int psyco_adapter_mxdatetime_init(void); HIDDEN PyObject *psyco_DateFromMx(PyObject *module, PyObject *args); diff --git a/psycopg/psycopgmodule.c b/psycopg/psycopgmodule.c index 6b79442..596ca31 100644 --- a/psycopg/psycopgmodule.c +++ b/psycopg/psycopgmodule.c @@ -970,13 +970,6 @@ mxdatetime_init(PyObject *module) if (mxDateTime_ImportModuleAndAPI()) { Dprintf("psycopgmodule: mx.DateTime module import failed"); PyErr_Clear(); - - /* only fail if the mx typacaster should have been the default */ -#ifdef PSYCOPG_DEFAULT_MXDATETIME - PyErr_SetString(PyExc_ImportError, - "can't import mx.DateTime module (requested as default adapter)"); - return -1; -#endif } /* If we can't find mx.DateTime objects at runtime, diff --git a/psycopg/typecast_datetime.c b/psycopg/typecast_datetime.c index d780400..7e5789b 100644 --- a/psycopg/typecast_datetime.c +++ b/psycopg/typecast_datetime.c @@ -458,10 +458,8 @@ typecast_PYINTERVAL_cast(const char *str, Py_ssize_t len, PyObject *curs) /* psycopg defaults to using python datetime types */ -#ifdef PSYCOPG_DEFAULT_PYDATETIME #define typecast_DATE_cast typecast_PYDATE_cast #define typecast_TIME_cast typecast_PYTIME_cast #define typecast_INTERVAL_cast typecast_PYINTERVAL_cast #define typecast_DATETIME_cast typecast_PYDATETIME_cast #define typecast_DATETIMETZ_cast typecast_PYDATETIMETZ_cast -#endif diff --git a/psycopg/typecast_mxdatetime.c b/psycopg/typecast_mxdatetime.c index ed0f99e..46147cc 100644 --- a/psycopg/typecast_mxdatetime.c +++ b/psycopg/typecast_mxdatetime.c @@ -240,13 +240,3 @@ typecast_MXINTERVAL_cast(const char *str, Py_ssize_t len, PyObject *curs) days, seconds); return mxDateTime.DateTimeDelta_FromDaysAndSeconds(days, seconds); } - -/* psycopg defaults to using mx types */ - -#ifdef PSYCOPG_DEFAULT_MXDATETIME -#define typecast_DATE_cast typecast_MXDATE_cast -#define typecast_TIME_cast typecast_MXTIME_cast -#define typecast_INTERVAL_cast typecast_MXINTERVAL_cast -#define typecast_DATETIME_cast typecast_MXDATE_cast -#define typecast_DATETIMETZ_cast typecast_MXDATE_cast -#endif |