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
This commit is contained in:
parent
ce2debce38
commit
af9f7b6cfa
@ -19,7 +19,6 @@
|
|||||||
#include "python-tg.h"
|
#include "python-tg.h"
|
||||||
|
|
||||||
extern struct tgl_state *TLS;
|
extern struct tgl_state *TLS;
|
||||||
|
|
||||||
// TGL Python Exceptions
|
// TGL Python Exceptions
|
||||||
extern PyObject *TglError;
|
extern PyObject *TglError;
|
||||||
extern PyObject *PeerError;
|
extern PyObject *PeerError;
|
||||||
@ -944,6 +943,9 @@ tgl_Peer_repr(tgl_Peer *self)
|
|||||||
|
|
||||||
switch(self->peer->id.type) {
|
switch(self->peer->id.type) {
|
||||||
case TGL_PEER_USER:
|
case TGL_PEER_USER:
|
||||||
|
#if PY_VERSION_HEX < 0x02070900
|
||||||
|
ret = PyUnicode_FromFormat("<tgl.Peer: id=%ld>", self->peer->id.id);
|
||||||
|
#else
|
||||||
ret = PyUnicode_FromFormat("<tgl.Peer: type=user, id=%ld, username=%R, name=%R, first_name=%R, last_name=%R, phone=%R>",
|
ret = PyUnicode_FromFormat("<tgl.Peer: type=user, id=%ld, username=%R, name=%R, first_name=%R, last_name=%R, phone=%R>",
|
||||||
self->peer->id.id,
|
self->peer->id.id,
|
||||||
PyObject_GetAttrString((PyObject*)self, "username"),
|
PyObject_GetAttrString((PyObject*)self, "username"),
|
||||||
@ -952,6 +954,7 @@ tgl_Peer_repr(tgl_Peer *self)
|
|||||||
PyObject_GetAttrString((PyObject*)self, "last_name"),
|
PyObject_GetAttrString((PyObject*)self, "last_name"),
|
||||||
PyObject_GetAttrString((PyObject*)self, "phone")
|
PyObject_GetAttrString((PyObject*)self, "phone")
|
||||||
);
|
);
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
case TGL_PEER_CHAT:
|
case TGL_PEER_CHAT:
|
||||||
ret = PyUnicode_FromFormat("<tgl.Peer: type=chat, id=%ld, name=%s>",
|
ret = PyUnicode_FromFormat("<tgl.Peer: type=chat, id=%ld, name=%s>",
|
||||||
@ -1423,7 +1426,9 @@ static PyObject *
|
|||||||
tgl_Msg_repr(tgl_Msg *self)
|
tgl_Msg_repr(tgl_Msg *self)
|
||||||
{
|
{
|
||||||
PyObject *ret;
|
PyObject *ret;
|
||||||
|
#if PY_VERSION_HEX < 0x02070900
|
||||||
|
ret = PyUnicode_FromFormat("<tgl.Msg id=%ld>", self->msg->id);
|
||||||
|
#else
|
||||||
ret = PyUnicode_FromFormat("<tgl.Msg id=%ld, flags=%d, mention=%R, out=%R, unread=%R, service=%R, src=%R, "
|
ret = PyUnicode_FromFormat("<tgl.Msg id=%ld, flags=%d, mention=%R, out=%R, unread=%R, service=%R, src=%R, "
|
||||||
"dest=%R, text=%R, media=%R, date=%R, fwd_src=%R, fwd_date=%R, reply_id=%R, reply=%R>",
|
"dest=%R, text=%R, media=%R, date=%R, fwd_src=%R, fwd_date=%R, reply_id=%R, reply=%R>",
|
||||||
self->msg->id, self->msg->flags,
|
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_id"),
|
||||||
PyObject_GetAttrString((PyObject*)self, "reply")
|
PyObject_GetAttrString((PyObject*)self, "reply")
|
||||||
);
|
);
|
||||||
|
#endif
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user