Python/Django

RuntimeError: maximum recursion depth exceeded while calling a Python object

S0PH1A 2018. 3. 18. 15:06
반응형

Django 프로젝트, 앱 생성시 아래와 같은 에러가 발생할 경우


File "C:\Python27\Lib\functools.py", line 56, in <lambda>

    '__lt__': [('__gt__', lambda self, other: other < self),

RuntimeError: maximum recursion depth exceeded while calling a Python object


C:\Python27\Lib\functools.py 에 Convert 부분을 다음과 같이 변경해 주면 된다.

def total_ordering(cls):
"""Class decorator that fills in missing ordering methods"""
# convert = {
# '__lt__': [('__gt__', lambda self, other: other < self),
# ('__le__', lambda self, other: not other < self),
# ('__ge__', lambda self, other: not self < other)],
# '__le__': [('__ge__', lambda self, other: other <= self),
# ('__lt__', lambda self, other: not other <= self),
# ('__gt__', lambda self, other: not self <= other)],
# '__gt__': [('__lt__', lambda self, other: other > self),
# ('__ge__', lambda self, other: not other > self),
# ('__le__', lambda self, other: not self > other)],
# '__ge__': [('__le__', lambda self, other: other >= self),
# ('__gt__', lambda self, other: not other >= self),
# ('__lt__', lambda self, other: not self >= other)]
# }
convert = {

'__lt__': [('__gt__', lambda self, other: not (self < other or self == other)),

('__le__', lambda self, other: self < other or self == other),

('__ge__', lambda self, other: not self < other)],

'__le__': [('__ge__', lambda self, other: not self <= other or self == other),

('__lt__', lambda self, other: self <= other and not self == other),

('__gt__', lambda self, other: not self <= other)],

'__gt__': [('__lt__', lambda self, other: not (self > other or self == other)),

('__ge__', lambda self, other: self > other or self == other),

('__le__', lambda self, other: not self > other)],

'__ge__': [('__le__', lambda self, other: (not self >= other) or self == other),

('__gt__', lambda self, other: self >= other and not self == other),

('__lt__', lambda self, other: not self >= other)]

}


반응형