From af9f7b6cfadc95be8b26f7f7901a847e1fed01c0 Mon Sep 17 00:00:00 2001 From: Vincent Castellano Date: Thu, 4 Jun 2015 21:25:49 -0700 Subject: [PATCH] Use a simple version of repr for Python < 2.7.9 This is due to a bug http://bugs.python.org/issue22023 This addresses https://github.com/vysheng/tg/issues/587 --- python-types.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/python-types.c b/python-types.c index 6d4413c..d909587 100644 --- a/python-types.c +++ b/python-types.c @@ -19,7 +19,6 @@ #include "python-tg.h" extern struct tgl_state *TLS; - // TGL Python Exceptions extern PyObject *TglError; extern PyObject *PeerError; @@ -944,7 +943,10 @@ tgl_Peer_repr(tgl_Peer *self) switch(self->peer->id.type) { case TGL_PEER_USER: - ret = PyUnicode_FromFormat("", +#if PY_VERSION_HEX < 0x02070900 + ret = PyUnicode_FromFormat("", self->peer->id.id); +#else + ret = PyUnicode_FromFormat("", self->peer->id.id, PyObject_GetAttrString((PyObject*)self, "username"), PyObject_GetAttrString((PyObject*)self, "name"), @@ -952,6 +954,7 @@ tgl_Peer_repr(tgl_Peer *self) PyObject_GetAttrString((PyObject*)self, "last_name"), PyObject_GetAttrString((PyObject*)self, "phone") ); +#endif break; case TGL_PEER_CHAT: ret = PyUnicode_FromFormat("", @@ -1423,7 +1426,9 @@ static PyObject * tgl_Msg_repr(tgl_Msg *self) { PyObject *ret; - +#if PY_VERSION_HEX < 0x02070900 + ret = PyUnicode_FromFormat("", self->msg->id); +#else ret = PyUnicode_FromFormat("", self->msg->id, self->msg->flags, @@ -1441,7 +1446,7 @@ tgl_Msg_repr(tgl_Msg *self) PyObject_GetAttrString((PyObject*)self, "reply_id"), PyObject_GetAttrString((PyObject*)self, "reply") ); - +#endif return ret; }