[pypy-dev] Allow subclassing `staticmethod` and `classmethod`
Carl Friedrich Bolz
cfbolz at gmx.de
Tue May 3 13:36:43 CEST 2011
Hi Ram,
On 05/03/2011 01:25 PM, cool-RR wrote:
> In my project I made an `abstract_static_method` class:
>
> https://github.com/cool-RR/GarlicSim/blob/master/garlicsim/garlicsim/general_misc/abc_tools.py#L7
>
> <https://github.com/cool-RR/GarlicSim/blob/master/garlicsim/garlicsim/general_misc/abc_tools.py#L7>A
> similar one has been made in Python 3.2:
>
> http://hg.python.org/cpython/file/default/Lib/abc.py#l48
>
>
> <http://hg.python.org/cpython/file/default/Lib/abc.py#l48>In Pypy this
> currently cannot be done, because if you subclass `staticmethod` into
> `abstractstaticmethod`, any instances will have a class
> of `staticmethod` instead of `abstractstaticmethod`:
>
> >>>> class A(staticmethod):
> .... pass
> ....
> >>>> def f():
> .... pass
> ....
> >>>> a = A(f)
> >>>> a
> <staticmethod object at 0x00f2ade0>
> >>>> type(a)
> <type 'staticmethod'>
>
>
> What can be done? I want to have `abstract_static_method` in my code.
This is a bug in PyPy, I fixed it in the repo, tomorrow you can use a
fresh nightly build from here:
http://buildbot.pypy.org/nightly/trunk/
Carl Friedrich
More information about the pypy-dev
mailing list