[py-dev] Re: [Python-Dev] Getting rid of unbound methods: patch available

Armin Rigo arigo at tunes.org
Mon Jan 17 12:27:26 CET 2005


Hi Holger & py.testers,

On Sun, Jan 16, 2005 at 10:12:37PM -0800, Guido van Rossum wrote:
> https://sourceforge.net/tracker/index.php?func=detail&aid=1103689&group_id=5470&atid=305470
> 
> Here's a patch that gets rid of unbound methods, as
> discussed here before. A function's __get__ method
> now returns the function unchanged when called without
> an instance, instead of returning an unbound method object.

This patch breaks py.test quite extensively, which is no surprise because it
contains a number of tests along the lines of hasattr(func, 'im_self').  
After a quick scan over py.test I'm not sure how easily this could be fixed,
and more importantly how easily it would be to fix it while still preserving
compatibility with existing Python versions.

The "hard" bit with removed unbound methods is that it's no longer possible to
find back the class C from which a function C.f was read (i.e. there is no
im_class any more).

I would suggest that we (I) give the issue some serious thoughts, and if it
really makes the life of the py lib difficult, it will be a good "real life"
example of breakage.  I'm sure it would be a good argument to postpone the
patch to the faraway ages usually called "Python 3000".


Armin



More information about the Pytest-dev mailing list