summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>2018-01-10 23:26:48 +0000
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>2018-01-10 23:26:48 +0000
commitbf58f3b1941efa854e70657856dc952bd8ff611b (patch)
tree6c70d95e1bab07bd3401bd2e3cd1a71eb6d4dcb7
parent72ed62dc8cad5cd57ec52e4136541e8751bc8169 (diff)
parent1477482e5982ec52ccf6a5e8f1e1836aea062452 (diff)
downloadpsycopg2-bf58f3b1941efa854e70657856dc952bd8ff611b.tar.gz
Merge branch 'datetime-macro-accessors' into maint_2_7
-rw-r--r--NEWS1
-rw-r--r--psycopg/adapter_datetime.c6
-rw-r--r--psycopg/python.h7
3 files changed, 12 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index 94f6bdb..d62df85 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,7 @@ What's new in psycopg 2.7.4
(:ticket:`632`).
- Fixed `~cursor.rowcount` after `~cursor.executemany()` with :sql:`RETURNING` statements
(:ticket:`633`).
+- Fixed compatibility problem with pypy3 (:ticket:`#649`).
- Wheel packages compiled against PostgreSQL 10.1 libpq and OpenSSL 1.0.2m.
diff --git a/psycopg/adapter_datetime.c b/psycopg/adapter_datetime.c
index 9d04df4..a78311e 100644
--- a/psycopg/adapter_datetime.c
+++ b/psycopg/adapter_datetime.c
@@ -100,7 +100,7 @@ _pydatetime_string_delta(pydatetimeObject *self)
char buffer[8];
int i;
- int a = obj->microseconds;
+ int a = PyDateTime_DELTA_GET_MICROSECONDS(obj);
for (i=0; i < 6 ; i++) {
buffer[5-i] = '0' + (a % 10);
@@ -109,7 +109,9 @@ _pydatetime_string_delta(pydatetimeObject *self)
buffer[6] = '\0';
return Bytes_FromFormat("'%d days %d.%s seconds'::interval",
- obj->days, obj->seconds, buffer);
+ PyDateTime_DELTA_GET_DAYS(obj),
+ PyDateTime_DELTA_GET_SECONDS(obj),
+ buffer);
}
static PyObject *
diff --git a/psycopg/python.h b/psycopg/python.h
index cfb8dad..ce8516d 100644
--- a/psycopg/python.h
+++ b/psycopg/python.h
@@ -93,6 +93,7 @@ typedef unsigned long Py_uhash_t;
#ifndef PyNumber_Int
#define PyNumber_Int PyNumber_Long
#endif
+
#endif /* PY_MAJOR_VERSION > 2 */
#if PY_MAJOR_VERSION < 3
@@ -128,6 +129,12 @@ typedef unsigned long Py_uhash_t;
#endif
+#ifndef PyDateTime_DELTA_GET_DAYS
+#define PyDateTime_DELTA_GET_DAYS(o) (((PyDateTime_Delta*)o)->days)
+#define PyDateTime_DELTA_GET_SECONDS(o) (((PyDateTime_Delta*)o)->seconds)
+#define PyDateTime_DELTA_GET_MICROSECONDS(o) (((PyDateTime_Delta*)o)->microseconds)
+#endif
+
HIDDEN PyObject *Bytes_Format(PyObject *format, PyObject *args);
/* Mangle the module name into the name of the module init function */