diff options
author | David Cramer <dcramer@gmail.com> | 2012-01-17 14:38:54 -0800 |
---|---|---|
committer | David Cramer <dcramer@gmail.com> | 2012-01-17 14:38:54 -0800 |
commit | a610ebfe89e45fc307d396716a2ae799e4c82618 (patch) | |
tree | 2b190d7d659b7057adcb3f22b66c431c4cfa4d2c | |
parent | ac8c044f114ff4a810e71dff25f7b6d2f2383028 (diff) | |
download | raven-a610ebfe89e45fc307d396716a2ae799e4c82618.tar.gz |
Gracefully handle invalid f_locals1.0.2
-rw-r--r-- | CHANGES | 4 | ||||
-rw-r--r-- | raven/utils/stacks.py | 16 | ||||
-rwxr-xr-x | setup.py | 2 |
3 files changed, 17 insertions, 5 deletions
@@ -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, @@ -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', |