summaryrefslogtreecommitdiff
path: root/psycopg/typecast_datetime.c
diff options
context:
space:
mode:
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>2021-06-14 23:46:39 +0100
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>2021-06-15 00:17:14 +0100
commitf28502663f1c318dd01c975cf70e3dcce544ab3b (patch)
tree1bf52dee88b416407560a43783758d58e76d23e0 /psycopg/typecast_datetime.c
parent2eac70786e7034888e43a316f05a39e6063253b6 (diff)
downloadpsycopg2-f28502663f1c318dd01c975cf70e3dcce544ab3b.tar.gz
Use datetime.timezone as default tzinfo_factory.
Diffstat (limited to 'psycopg/typecast_datetime.c')
-rw-r--r--psycopg/typecast_datetime.c13
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; }