I frequently encounter this error in Mako templates using Pylons 0.9.7:
AttributeError: 'NoneType' object has no attribute 'decode'
Usually I've entered a variable name that doesn't exist, tried to use a linbebreak within a code line, or some other minor error. Definitely my fault.
This results in a 'Internal Server Error' in the browser, same thing in the debug view, and a stack trace that starts in HTTPServer and ends with the AttributeError in mako/exceptions.py.
Is there anything I can do to make this easier to debug, like find out the line that exception is being generated on within the Mako template? Thanks!
In my case, it turns out there was a division by 0 error in my template. That was yielding an internal server error, and a very unhelpful stack trace in console output.
I know, it sounds like I shouldn't have had that logic in a template anyway, but in this case, I think it makes sense to do so. Here's the stack trace I get with division by 0: