summaryrefslogtreecommitdiff
path: root/psycopg/microprotocols.c
diff options
context:
space:
mode:
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>2010-12-12 21:48:54 +0000
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>2010-12-21 04:24:36 +0000
commitcb6b52945b4c114d39613e6a7b35c73762e5045f (patch)
tree30fd118d454aa4008174f0aac71fc15023612867 /psycopg/microprotocols.c
parente182201e6ee8075a88b63c9d8338f833bd2471b0 (diff)
downloadpsycopg2-cb6b52945b4c114d39613e6a7b35c73762e5045f.tar.gz
The library can be compiled with Python 3.
Just compiled! No test run yet and many points to review, marked in the code. The patch is largely Martin von Löwis work, simplified after refactoring in the previous commits and adapted to the new code (as the patch was originally for Psycopg 2.0.9)
Diffstat (limited to 'psycopg/microprotocols.c')
-rw-r--r--psycopg/microprotocols.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/psycopg/microprotocols.c b/psycopg/microprotocols.c
index f41d85f..067729f 100644
--- a/psycopg/microprotocols.c
+++ b/psycopg/microprotocols.c
@@ -83,7 +83,11 @@ _get_superclass_adapter(PyObject *obj, PyObject *proto)
Py_ssize_t i, ii;
type = Py_TYPE(obj);
- if (!((Py_TPFLAGS_HAVE_CLASS & type->tp_flags) && type->tp_mro)) {
+ if (!(
+#if PY_MAJOR_VERSION < 3
+ (Py_TPFLAGS_HAVE_CLASS & type->tp_flags) &&
+#endif
+ type->tp_mro)) {
/* has no mro */
return NULL;
}
@@ -134,7 +138,7 @@ microprotocols_adapt(PyObject *obj, PyObject *proto, PyObject *alt)
/* None is always adapted to NULL */
if (obj == Py_None)
- return PyString_FromString("NULL");
+ return Text_FromUTF8("NULL");
Dprintf("microprotocols_adapt: trying to adapt %s",
Py_TYPE(obj)->tp_name);