django启动的时候报错RuntimeError: maximum recursion depth exceeded in cmp

django启动的时候报了错

py2.7,django1.9

python manage.py runserver

报错如下:

Unhandled exception in thread started by <function wrapper at 0x2d7e410>
Traceback (most recent call last):
  File "/root/virtual_dir/wxwebapp_court_nositepkg/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
    fn(*args, **kwargs)
   .......................省略N多行
  File "/usr/local/lib/python2.7/functools.py", line 56, in <lambda>
    '__lt__': [('__gt__', lambda self, other: other < self),
  .......................省略N多行,重复报上面的错
RuntimeError: maximum recursion depth exceeded in cmp


出错地方是/usr/local/lib/python2.7/functools.py", line 56

找到functools.py看下,56行开始如下:
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)]
    }

因为是新手,lambda的作用我也不是很熟悉,简单的理解就是lambda 后面跟参数,然后冒号后面执行语句,有点像匿名函数的意思

例如:
add=lambda a:a*2
add(2)
输出4

count=lambda a,b:a+b
count(3,6)
输出9

回归正题,修改如下,当然这不是我写的,我在win10运行是正常的,去到centOS就报错了,我就对比下两者之间的差异,发
现两个写的不一样,下面是正常的,我把下面正常的逻辑,覆盖上面错误的逻辑,在centOS可以正常运行了

(就是找到functools.py ,把下面的内容覆盖原来错误的56行那一块内容,我是用xshell和xftp的,直接拿到本地改了放回去)

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

猜你喜欢

转载自blog.csdn.net/p312011150/article/details/80075108