A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2007-November/075359.html below:

[Python-Dev] Should we do away with unbound methods in Py3k?

[Python-Dev] Should we do away with unbound methods in Py3k?Guido van Rossum guido at python.org
Sat Nov 24 18:56:40 CET 2007
On Nov 23, 2007 11:10 PM, Christian Heimes <lists at cheimes.de> wrote:
> Guido van Rossum wrote:
> >
> > 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]
>
> I've created a preliminary patch. Several unit tests are still failing.

Thanks for the patch! Now I'm hoping someone will look into those
remaining six test failures.

Also, there was discussion of this before:
http://mail.python.org/pipermail/python-dev/2005-January/050625.html
-- why didn't we decide to do it then?

> The patch is also changing some semantics. For example in Python 2.5:
>
> >>> import inspect
> >>> class Class(object):
> ...     def method(self): pass
> ...
> >>> inspect.ismethod(Class().method)
> True
> >>> inspect.ismethod(Class.method)
> True
>
> But in py3k:
>
> >>> import inspect
> >>> class Class:
> ...     def method(self): pass
> ...
> >>> inspect.ismethod(Class().method)
> True
> >>> inspect.ismethod(Class.method)
> False # !!!

As it should be.


-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4