Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

magic-removal: Fixes #1396 -- Added exception handler (and silent_var…

…iable_failure check) for edge case in descriptor lookup.

git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2604 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 0d6f2f87072f75e9ca8bacc2dfd9e64f245a809a 1 parent 859e652
Russell Keith-Magee freakboy3742 authored
Showing with 7 additions and 2 deletions.
  1. +7 −2 django/template/__init__.py
9 django/template/__init__.py
View
@@ -603,9 +603,9 @@ def resolve_variable(path, context):
if path[0] in '0123456789':
number_type = '.' in path and float or int
try:
- current = number_type(path)
+ current = number_type(path)
except ValueError:
- current = settings.TEMPLATE_STRING_IF_INVALID
+ current = settings.TEMPLATE_STRING_IF_INVALID
elif path[0] in ('"', "'") and path[0] == path[-1]:
current = path[1:-1]
else:
@@ -637,6 +637,11 @@ def resolve_variable(path, context):
current = current[int(bits[0])]
except (IndexError, ValueError, KeyError):
raise VariableDoesNotExist, "Failed lookup for key [%s] in %r" % (bits[0], current) # missing attribute
+ except Exception, e:
+ if getattr(e, 'silent_variable_failure', False):
+ current = settings.TEMPLATE_STRING_IF_INVALID
+ else:
+ raise
del bits[0]
return current
Please sign in to comment.
Something went wrong with that request. Please try again.