diff options
author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2021-06-14 23:46:39 +0100 |
---|---|---|
committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2021-06-15 00:17:14 +0100 |
commit | f28502663f1c318dd01c975cf70e3dcce544ab3b (patch) | |
tree | 1bf52dee88b416407560a43783758d58e76d23e0 /psycopg/typecast_datetime.c | |
parent | 2eac70786e7034888e43a316f05a39e6063253b6 (diff) | |
download | psycopg2-f28502663f1c318dd01c975cf70e3dcce544ab3b.tar.gz |
Use datetime.timezone as default tzinfo_factory.
Diffstat (limited to 'psycopg/typecast_datetime.c')
-rw-r--r-- | psycopg/typecast_datetime.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/psycopg/typecast_datetime.c b/psycopg/typecast_datetime.c index d700069..121a228 100644 --- a/psycopg/typecast_datetime.c +++ b/psycopg/typecast_datetime.c @@ -104,9 +104,18 @@ _parse_inftz(const char *str, PyObject *curs) goto exit; } - if (!(tzinfo = PyObject_CallFunction(tzinfo_factory, "i", 0))) { - goto exit; +#if PY_VERSION_HEX < 0x03070000 + { + PyObject *tzoff; + if (!(tzoff = PyDelta_FromDSU(0, 0, 0))) { goto exit; } + tzinfo = PyObject_CallFunctionObjArgs(tzinfo_factory, tzoff, NULL); + Py_DECREF(tzoff); + if (!tzinfo) { goto exit; } } +#else + tzinfo = PyDateTime_TimeZone_UTC; + Py_INCREF(tzinfo); +#endif /* m.replace(tzinfo=tzinfo) */ if (!(args = PyTuple_New(0))) { goto exit; } |