catcher icon indicating copy to clipboard operation
catcher copied to clipboard

Strange behaviour with Flask

Open mratozar opened this issue 10 years ago • 4 comments

Simple example (yes, Flask is imported but not used):

import sys

from flask import Flask
import catcher


def exception_handler(exc_type, exc, tb):
    exc.traceback_backup = tb
    report = catcher.collect(exc)
    print catcher.formatters.HTMLFormatter().format(report)


def fail():
    1 / 0


sys.excepthook = exception_handler
fail()

I get the error:

Error in sys.excepthook:
Traceback (most recent call last):
  File "example.py", line 11, in exception_handler
    print catcher.formatters.HTMLFormatter().format(report)
  File "/home/eslezko/.virtualenvs/marylin/local/lib/python2.7/site-packages/catcher/formatters/html.py", line 161, in format
    return _template.render(maxdepth=maxdepth, report=report, datetime=datetime)
  File "/home/eslezko/.virtualenvs/marylin/local/lib/python2.7/site-packages/mako/template.py", line 412, in render
    return runtime._render(self, self.callable_, args, data)
  File "/home/eslezko/.virtualenvs/marylin/local/lib/python2.7/site-packages/mako/runtime.py", line 766, in _render
    **_kwargs_for_callable(callable_, data))
  File "/home/eslezko/.virtualenvs/marylin/local/lib/python2.7/site-packages/mako/runtime.py", line 798, in _render_context
    _exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
  File "/home/eslezko/.virtualenvs/marylin/local/lib/python2.7/site-packages/mako/runtime.py", line 824, in _exec_template
    callable_(context, *args, **kwargs)
  File "memory:0x1ea6450", line 95, in render_body
  File "memory:0x1ea6450", line 19, in object
  File "memory:0x1ea6450", line 160, in render_object
  File "memory:0x1ea6450", line 112, in object
  File "memory:0x1ea6450", line 196, in render_object
  File "memory:0x1ea6450", line 112, in object
  File "memory:0x1ea6450", line 160, in render_object
  File "memory:0x1ea6450", line 112, in object
  File "memory:0x1ea6450", line 150, in render_object
RuntimeError: dictionary changed size during iteration

Original exception was:
Traceback (most recent call last):
  File "example.py", line 19, in <module>
    fail()
  File "example.py", line 15, in fail
    1 / 0
ZeroDivisionError: integer division or modulo by zero

Without flask import catcher works well.

mratozar avatar Jul 31 '13 10:07 mratozar

Works fine for me. Please include your versions of mako and flask

Eugeny avatar Jul 31 '13 10:07 Eugeny

Flask==0.9 Mako==0.7.2

mratozar avatar Jul 31 '13 10:07 mratozar

Still not reproducable. Can you create and zip a virtualenv with which the bug happens?

Eugeny avatar Jul 31 '13 10:07 Eugeny

Here it is: https://dl.dropboxusercontent.com/u/62547315/catcher.zip

mratozar avatar Jul 31 '13 14:07 mratozar