Author josh.r
Recipients Christophe Simonis, belopolsky, jackdied, josh.r, pitrou, rhettinger, vdupras
Date 2014-10-06.22:55:18
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1412636119.12.0.124529252184.issue7830@psf.upfronthosting.co.za>
In-reply-to
Content
The use case in question, simplified, was:

from functools import partial

class Foo:
    Bar = othermodule.Bar

    def __new__(cls, ...):
        ...
        cls.Bar(...)
        ...

    def bind_stuff(cls, *args, **kwargs):
        cls.Bar = partial(Bar, *args, **kwargs)

Every time they created an instance of Foo, there would be a Foo.bind_stuff call beforehand that fixed some settings they didn't want to make a part of Foo's __new__ profile. And in fact, in practice, they were only binding the same keyword args over and over, so they could have solved the problem by just rebinding the base othermodule.Bar. I'm not defending this design, but from what I can tell, it's a textbook example of where your patch would solve the problem. cls.Bar has no instance variables assigned (hence no __dict__?), and it's always functools.partial that's used, not some special variant.

A simple way to repro the fundamental problem they were experiencing is to just wrap int a lot:

>>> for i in range(1001):
        int = partial(int)
>>> int(5) # Kaboom! Which I assume your patch would prevent
History
Date User Action Args
2014-10-06 22:55:19josh.rsetrecipients: + josh.r, rhettinger, belopolsky, pitrou, jackdied, vdupras, Christophe Simonis
2014-10-06 22:55:19josh.rsetmessageid: <1412636119.12.0.124529252184.issue7830@psf.upfronthosting.co.za>
2014-10-06 22:55:19josh.rlinkissue7830 messages
2014-10-06 22:55:18josh.rcreate