Skip to content

Strange behaviour with Flask #2

@mratozar

Description

@mratozar

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions