Mercurial > cpython-lru_cache-weakref
diff Objects/weakrefobject.c @ 57348:42aaedaefbcb 3.1
Merged revisions 76396 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
................
r76396 | benjamin.peterson | 2009-11-18 21:08:32 -0600 (Wed, 18 Nov 2009) | 10 lines
fix __bytes__ handling here in py3x
Merged revisions 76395 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r76395 | benjamin.peterson | 2009-11-18 21:00:02 -0600 (Wed, 18 Nov 2009) | 1 line
#5037 proxy __unicode__ correctly
........
................
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Thu, 19 Nov 2009 03:10:36 +0000 |
| parents | 87fbbf22adf3 |
| children | cab14be0ada1 |
line wrap: on
line diff
--- a/Objects/weakrefobject.c Thu Nov 19 01:23:41 2009 +0000 +++ b/Objects/weakrefobject.c Thu Nov 19 03:10:36 2009 +0000 @@ -435,6 +435,13 @@ return generic(proxy, v, w); \ } +#define WRAP_METHOD(method, special) \ + static PyObject * \ + method(PyObject *proxy) { \ + UNWRAP(proxy); \ + return PyObject_CallMethod(proxy, special, ""); \ + } + /* direct slots */ @@ -576,6 +583,15 @@ } +WRAP_METHOD(proxy_bytes, "__bytes__"); + + +static PyMethodDef proxy_methods[] = { + {"__bytes__", (PyCFunction)proxy_bytes, METH_NOARGS}, + {NULL, NULL} +}; + + static PyNumberMethods proxy_as_number = { proxy_add, /*nb_add*/ proxy_sub, /*nb_subtract*/ @@ -661,6 +677,7 @@ 0, /* tp_weaklistoffset */ (getiterfunc)proxy_iter, /* tp_iter */ (iternextfunc)proxy_iternext, /* tp_iternext */ + proxy_methods, /* tp_methods */ };
