2012/1/7 Maciej Fijalkowski <[email protected]>
> > I am curious that does it hard for pypy to add those data type?
> > like PyByteArray_Type, PyMemoryView_Type and PyInterpreterState
>
> It's usually a painful experience to add new stuff to cpyext. But
> also, it does not necesarilly give you confidence that it'll work,
> since emulating CPython C API is tricky and tiny problems with
> refcounts can lead to segfaults that don't occur on cpython for
> obscure reasons.
I looked at the compilation messages, and added the missing parts;
it was not that difficult, after all :-)
The module should now compile, provided you apply the attached patch to
psycopg.
(I suggested the PyDateTime_DELTA_GET_DAYS macros to CPython:
http://bugs.python.org/issue13727 )
The resulting module works a little... at least it yielded a meaningful
error message:
$ ./pypy-c -c "import psycopg2; conn = psycopg2.connect('dbname=test')"
OperationalError: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
--
Amaury Forgeot d'Arc
--- psycopg2-2.4.4/psycopg/adapter_datetime.c~ 2011-02-06 16:58:34.000000000 +0100
+++ psycopg2-2.4.4/psycopg/adapter_datetime.c 2012-01-07 13:58:29.335849554 +0100
@@ -38,6 +38,12 @@
extern HIDDEN PyObject *pyPsycopgTzModule;
extern HIDDEN PyObject *pyPsycopgTzLOCAL;
+#ifndef PyDateTime_DELTA_GET_DAYS
+#define PyDateTime_DELTA_GET_DAYS(obj) ((obj)->days)
+#define PyDateTime_DELTA_GET_SECONDS(obj) ((obj)->seconds)
+#define PyDateTime_DELTA_GET_MICROSECONDS(obj) ((obj)->microseconds)
+#endif
+
int
psyco_adapter_datetime_init(void)
{
@@ -100,7 +106,7 @@
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 +115,9 @@
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 *
_______________________________________________
pypy-dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-dev