You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to get the doc_inherit recipe (576862) to work with my classes, and the problem is that sometimes I have classes that go 2 levels down from the base class, rather than just one. This leads to an infinite recursion when the middle layer uses doc_inherit for a method.
Here is a minimal case that reproduces my problem:
from recipe_576862 import doc_inherit
class Base(object):
def foo(self):
"Base class foo"
pass
class Mid(Base):
@doc_inherit
def foo(self):
# Should inherit doc string from Base
pass
class Final(Mid):
def __init__(self): pass
obj = Final()
obj.foo()
The output is:
python doc-inherit-bug.py
Traceback (most recent call last):
File "doc-inherit-bug.py", line 22, in <module>
obj.foo()
File "/Users/Mike/Downloads/recipe_576862.py", line 34, in __get__
return self.get_with_inst(obj, cls)
File "/Users/Mike/Downloads/recipe_576862.py", line 40, in get_with_inst
overridden = getattr(super(cls, obj), self.name, None)
[snip]
File "/Users/Mike/Downloads/recipe_576862.py", line 34, in __get__
return self.get_with_inst(obj, cls)
File "/Users/Mike/Downloads/recipe_576862.py", line 40, in get_with_inst
overridden = getattr(super(cls, obj), self.name, None)
RuntimeError: maximum recursion depth exceeded while calling a Python object
Unfortunately, I don't understand python's super well enough to figure out how to fix it. Anyone have an idea how the recipe could be tweaked to allow this use case?
Thanks so much for your help.
The text was updated successfully, but these errors were encountered:
I'm trying to get the doc_inherit recipe (576862) to work with my classes, and the problem is that sometimes I have classes that go 2 levels down from the base class, rather than just one. This leads to an infinite recursion when the middle layer uses doc_inherit for a method.
Here is a minimal case that reproduces my problem:
The output is:
Unfortunately, I don't understand python's
super
well enough to figure out how to fix it. Anyone have an idea how the recipe could be tweaked to allow this use case?Thanks so much for your help.
The text was updated successfully, but these errors were encountered: