summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Cramer <dcramer@gmail.com>2012-01-17 14:38:54 -0800
committerDavid Cramer <dcramer@gmail.com>2012-01-17 14:38:54 -0800
commita610ebfe89e45fc307d396716a2ae799e4c82618 (patch)
tree2b190d7d659b7057adcb3f22b66c431c4cfa4d2c
parentac8c044f114ff4a810e71dff25f7b6d2f2383028 (diff)
downloadraven-a610ebfe89e45fc307d396716a2ae799e4c82618.tar.gz
Gracefully handle invalid f_locals1.0.2
-rw-r--r--CHANGES4
-rw-r--r--raven/utils/stacks.py16
-rwxr-xr-xsetup.py2
3 files changed, 17 insertions, 5 deletions
diff --git a/CHANGES b/CHANGES
index 07e4c39..713724d 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,7 @@
+1.0.2
+
+* Gracefully handle invalid f_locals.
+
1.0.1
* All datetimes are assumed to be utcnow() as of Sentry 2.0.0-RC5
diff --git a/raven/utils/stacks.py b/raven/utils/stacks.py
index 6048a54..0d01590 100644
--- a/raven/utils/stacks.py
+++ b/raven/utils/stacks.py
@@ -100,7 +100,8 @@ def iter_traceback_frames(tb):
while tb:
# support for __traceback_hide__ which is used by a few libraries
# to hide internal frames.
- if not tb.tb_frame.f_locals.get('__traceback_hide__'):
+ f_locals = tb.tb_frame.f_locals
+ if not (isinstance(f_locals, dict) and f_locals.get('__traceback_hide__')):
yield tb.tb_frame
tb = tb.tb_next
@@ -109,7 +110,8 @@ def iter_stack_frames(frames=None):
if not frames:
frames = inspect.stack()[1:]
for frame in (f[0] for f in frames):
- if frame.f_locals.get('__traceback_hide__'):
+ f_locals = frame.f_locals
+ if (isinstance(f_locals, dict) or f_locals.get('__traceback_hide__')):
continue
yield frame
@@ -118,7 +120,8 @@ def get_stack_info(frames):
results = []
for frame in frames:
# Support hidden frames
- if frame.f_locals.get('__traceback_hide__'):
+ f_locals = frame.f_locals
+ if (isinstance(f_locals, dict) or f_locals.get('__traceback_hide__')):
continue
abs_path = frame.f_code.co_filename
@@ -137,6 +140,11 @@ def get_stack_info(frames):
filename = abs_path
if context_line:
+ f_locals = frame.f_locals
+ if not isinstance(f_locals, dict):
+ # XXX: Genshi (and maybe others) have broken implementations of
+ # f_locals that are not actually dictionaries
+ f_locals = '<invalid local scope>'
results.append({
'abs_path': abs_path,
'filename': filename or abs_path,
@@ -144,7 +152,7 @@ def get_stack_info(frames):
'function': function,
'lineno': lineno + 1,
# TODO: vars need to be references
- 'vars': transform(frame.f_locals),
+ 'vars': transform(f_locals),
'pre_context': pre_context,
'context_line': context_line,
'post_context': post_context,
diff --git a/setup.py b/setup.py
index a9c4733..b878814 100755
--- a/setup.py
+++ b/setup.py
@@ -31,7 +31,7 @@ install_requires = [
setup(
name='raven2',
- version='1.0.1',
+ version='1.0.2',
author='David Cramer',
author_email='dcramer@gmail.com',
url='http://github.com/dcramer/raven',