[Python-Dev] Should we do away with unbound methods in Py3k?
Guido van Rossum
guido at python.org
Sat Nov 24 06:17:44 CET 2007
More information about the Python-Dev mailing list
Sat Nov 24 06:17:44 CET 2007
- Previous message: [Python-Dev] Should we do away with unbound methods in Py3k?
- Next message: [Python-Dev] Should we do away with unbound methods in Py3k?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Nov 22, 2007 11:12 PM, Christian Heimes <lists at cheimes.de> wrote: > Guido van Rossum wrote: > > It looks like we're in agreement to drop unbound methods and have a > > reasonable set or arguments around it (e.g. keep staticmethod, no > > changes to methods of builtin types, etc.). Do we need a PEP? It's > > essentially a 2-line change in funcobject.c (func_descr_get()) -- plus > > fixing up half a dozen or so unittests that specifically seem to test > > the behavior of unbound methods. > > I'd like to help but after staring at the code for 10 minutes I still > don't get how the descriptor function should be altered. Can you please > give an example to a mer mortal? :) Index: Objects/funcobject.c =================================================================== --- Objects/funcobject.c (revision 59154) +++ Objects/funcobject.c (working copy) @@ -643,8 +643,10 @@ static PyObject * func_descr_get(PyObject *func, PyObject *obj, PyObject *type) { - if (obj == Py_None) - obj = NULL; + if (obj == Py_None || obj == NULL) { + Py_INCREF(func); + return func; + } return PyMethod_New(func, obj, type); } [well, except those should be tabs not spaces] -- --Guido van Rossum (home page: http://www.python.org/~guido/)
- Previous message: [Python-Dev] Should we do away with unbound methods in Py3k?
- Next message: [Python-Dev] Should we do away with unbound methods in Py3k?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list