[Fixed]-Django: python manage.py runserver gives RuntimeError: maximum recursion depth exceeded in cmp

39πŸ‘

βœ…

The problem is in functools.py file. This file is from Python. I have just installed a new version of python 2.7.5 and this file is wrong (I have another – older installation of python 2.7.5 and there the file functools.py is correct)

To fix the problem replace this (about line 56 in python\Lib\fuctools.py):

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)]
}

to that:

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)]
}

Read also: http://regebro.wordpress.com/2010/12/13/python-implementing-rich-comparison-the-correct-way/

πŸ‘€tstempko

2πŸ‘

You have likely run into this bug: http://bugs.python.org/issue10042

Exactly what happens is hard to tell without debugging, bit I’d guess one of the things that should be a field isn’t in this line:

self.local_fields.insert(bisect(self.local_fields, field), field)

2πŸ‘

I had this problem here, today.

We were using django1.5.1 and python2.7.2 too.

At first we were installed django1.4 and it worked, but the project has django1.5 features, so it’s not a total solution.

To solve this we installed python2.7.5 and it worked fine!

0πŸ‘

just use this :
python manage.py migrate

Leave a comment