mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-11 03:26:37 +03:00
Added typecasters repr().
This commit is contained in:
parent
b4685bba4a
commit
b5ef5ef21d
|
@ -426,6 +426,24 @@ typecast_del(void *self)
|
|||
PyObject_GC_Del(self);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
typecast_repr(PyObject *self)
|
||||
{
|
||||
PyObject *name = ((typecastObject *)self)->name;
|
||||
PyObject *bname;
|
||||
PyObject *rv;
|
||||
|
||||
if (!(bname = psycopg_ensure_bytes(name))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
rv = PyString_FromFormat("<%s '%s' at %p>",
|
||||
Py_TYPE(self)->tp_name, PyBytes_AS_STRING(name), self);
|
||||
|
||||
Py_DECREF(bname);
|
||||
return rv;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
typecast_call(PyObject *obj, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
|
@ -458,7 +476,7 @@ PyTypeObject typecastType = {
|
|||
0, /*tp_getattr*/
|
||||
0, /*tp_setattr*/
|
||||
typecast_cmp, /*tp_compare*/
|
||||
0, /*tp_repr*/
|
||||
typecast_repr, /*tp_repr*/
|
||||
0, /*tp_as_number*/
|
||||
0, /*tp_as_sequence*/
|
||||
0, /*tp_as_mapping*/
|
||||
|
|
Loading…
Reference in New Issue
Block a user