summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2009-11-19 03:00:02 (GMT)
committerBenjamin Peterson <benjamin@python.org>2009-11-19 03:00:02 (GMT)
commitdc3c239b1ef694b36c79008cdb86ed18852f63c1 (patch)
tree56525a6dfc066fc13bf7a1ce341c85fef4608a11 /Objects
parent9eac119ba8f9fd6d76b75689baaa656a979cc260 (diff)
downloadcpython-dc3c239b1ef694b36c79008cdb86ed18852f63c1.zip
cpython-dc3c239b1ef694b36c79008cdb86ed18852f63c1.tar.gz
cpython-dc3c239b1ef694b36c79008cdb86ed18852f63c1.tar.bz2
#5037 proxy __unicode__ correctly
Diffstat (limited to 'Objects')
-rw-r--r--Objects/weakrefobject.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c
index 9cdd021..1a998b6 100644
--- a/Objects/weakrefobject.c
+++ b/Objects/weakrefobject.c
@@ -433,6 +433,13 @@ proxy_checkref(PyWeakReference *proxy)
return generic(proxy, v, w); \
}
+#define WRAP_METHOD(method, special) \
+ static PyObject * \
+ method(PyObject *proxy) { \
+ UNWRAP(proxy); \
+ return PyObject_CallMethod(proxy, special, ""); \
+ }
+
/* direct slots */
@@ -593,6 +600,15 @@ proxy_iternext(PyWeakReference *proxy)
}
+WRAP_METHOD(proxy_unicode, "__unicode__");
+
+
+static PyMethodDef proxy_methods[] = {
+ {"__unicode__", (PyCFunction)proxy_unicode, METH_NOARGS},
+ {NULL, NULL}
+};
+
+
static PyNumberMethods proxy_as_number = {
proxy_add, /*nb_add*/
proxy_sub, /*nb_subtract*/
@@ -684,6 +700,7 @@ _PyWeakref_ProxyType = {
0, /* tp_weaklistoffset */
(getiterfunc)proxy_iter, /* tp_iter */
(iternextfunc)proxy_iternext, /* tp_iternext */
+ proxy_methods, /* tp_methods */
};