1

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?

AncientSwordRage
  • 7,086
  • 19
  • 90
  • 173

2 Answers2

1

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

AncientSwordRage
  • 7,086
  • 19
  • 90
  • 173
  • Actually, you don't need to pass the `e` argument (if that's an exception itself, as it usually is) to format_exc() at all. See here https://docs.python.org/library/traceback.html – sm4rk0 Sep 13 '17 at 10:20
  • @sm4rk0 I don't see anything in their that indicates that. – AncientSwordRage Sep 25 '17 at 10:56
  • `format_exc` takes two optional parameters: `limit` (default=None) and `chain` (default=True). None of them is of `Exception` type. Try it without the arguments. – sm4rk0 Sep 27 '17 at 13:49
  • @sm4rk0 I did, see my question. It may have changed across versions. – AncientSwordRage Sep 28 '17 at 08:24
0

Try with this (no e argument):

sys.stderr.write(exceptions.traceback.format_exc())
sm4rk0
  • 473
  • 4
  • 17