Traceback.py 尝试比较解析为 ImportError 的 'limit'

Traceback.py tries to compare int and 'limit' which resolves to an ImportError

我正在尝试 lettuce to run on python 3, and it's not been working. So I quickly 2to3 处理所有有问题的文件,现在我遇到了这个问题:

当处理找不到地形时,生菜由于这条线而崩溃

sys.stderr.write(exceptions.traceback.format_exc(e))

这是因为:

   while curr is not None and (limit is None or n < limit):

Limit 是一个 ImportError,不能与 n 比较,后者是 int!

我该如何解决这个问题?

python3中def format_exc(limit=None, chain=True):的格式意味着你指定e的kwarg,在你的错误中:

sys.stderr.write(exceptions.traceback.format_exc(e))

必须(通过淘汰)

sys.stderr.write(exceptions.traceback.format_exc(chain=e))

调用假设 e 对应于 limit

的第一个 kwarg

试试这个(没有 e 参数):

sys.stderr.write(exceptions.traceback.format_exc())