首页 > 学院 > 开发设计 > 正文

运行django出现递归报错的解决办法

2019-11-11 04:09:32
字体:
来源:转载
供稿:网友

在运行django程序的时候,出现下面的问题

RuntimeError: maximum recursion depth exceeded in cmp

说是递归深度有问题,在网上查了好久,终于解决了。

原来是python自己的问题,需要将fuctools.py进行修改。具体如下

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)]}
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表