From 49f9e65fd6fe53cfcfc341691854caef4f136082 Mon Sep 17 00:00:00 2001 From: Nejc Zupan Date: Tue, 9 Jul 2013 12:13:50 +0200 Subject: [PATCH] Handle recursion errors In some cases, for example when a frame is App.ZApplication.ZApplicationWrapper, then "frame.f_locals.get('self', None)" raises a maximum recursion depth error. This fix catches these and moves further so Zope continues to run (without the fix Zope breaks) and we still get a (request-less) error report in Sentry. --- raven/contrib/zope/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/raven/contrib/zope/__init__.py b/raven/contrib/zope/__init__.py index 01386e8b3..126a62df9 100644 --- a/raven/contrib/zope/__init__.py +++ b/raven/contrib/zope/__init__.py @@ -55,7 +55,10 @@ def emit(self, record): request = frame.f_locals.get('request', None) if not request: view = frame.f_locals.get('self', None) - request = getattr(view, 'request', None) + try: + request = getattr(view, 'request', None) + except RuntimeError: + request = None if not exc_info: exc_info = frame.f_locals.get('exc_info', None) if not hasattr(exc_info, '__getitem__'):