Search code examples
pythonlettucepython-2to3

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


I'm trying to get lettuce to run on python 3, and it's not been working. So I quickly 2to3'd all the offending files, and now I get this issue:

When handling not finding terrain, lettuce crashes out due to this line

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

Which is due to this:

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

Limit is an ImportError and cannot be compared to n, which an int!

How do I get around this?


Solution

  • The format of def format_exc(limit=None, chain=True): in python3 means you have to specify the kwarg of e, in your error:

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

    Must be (by elimination)

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

    The call was assuming that e corresponded to the first kwarg of limit