Author: cito
Date: Sun Nov 22 07:05:24 2015
New Revision: 594

Log:
Python 3 does not support tp_print any more

Modified:
   trunk/module/pgmodule.c

Modified: trunk/module/pgmodule.c
==============================================================================
--- trunk/module/pgmodule.c     Sun Nov 22 06:25:47 2015        (r593)
+++ trunk/module/pgmodule.c     Sun Nov 22 07:05:24 2015        (r594)
@@ -964,17 +964,15 @@
        return PyObject_GenericGetAttr((PyObject *) self, nameobj);
 }
 
-/* prints query object in human readable format */
-static int
-largePrint(largeObject *self, FILE *fp, int flags)
+/* output large object as string */
+static PyObject *
+largeStr(largeObject *self)
 {
-       char            print_buffer[128];
-       PyOS_snprintf(print_buffer, sizeof(print_buffer),
-               self->lo_fd >= 0 ?
+       char            str[80];
+       sprintf(str, self->lo_fd >= 0 ?
                        "Opened large object, oid %ld" :
                        "Closed large object, oid %ld", (long) self->lo_oid);
-       fputs(print_buffer, fp);
-       return 0;
+       return PyStr_FromString(str);
 }
 
 static char large__doc__[] = "PostgreSQL large object";
@@ -988,7 +986,7 @@
 
        /* methods */
        (destructor) largeDealloc,              /* tp_dealloc */
-       (printfunc) largePrint,                 /* tp_print */
+       0,                                                              /* 
tp_print */
        0,                                                              /* 
tp_getattr */
        0,                                                              /* 
tp_setattr */
        0,                                                              /* 
tp_compare */
@@ -998,7 +996,7 @@
        0,                                                              /* 
tp_as_mapping */
        0,                                                              /* 
tp_hash */
        0,                              /* tp_call */
-       0,                                                              /* 
tp_str */
+       (reprfunc) largeStr,                    /* tp_str */
        (getattrofunc) largeGetAttr,    /* tp_getattro */
        0,                              /* tp_setattro */
        0,                              /* tp_as_buffer */
@@ -1411,6 +1409,7 @@
        return PyStr_FromString("<pg query result>");
 }
 
+/* output query as string */
 static PyObject *
 queryStr(queryObject *self)
 {
@@ -3594,6 +3593,7 @@
        return PyObject_GenericGetAttr((PyObject *) self, nameobj);
 }
 
+/* output notice as string */
 static PyObject *
 noticeStr(noticeObject *self)
 {
_______________________________________________
PyGreSQL mailing list
[email protected]
https://mail.vex.net/mailman/listinfo.cgi/pygresql

Reply via email to