Ticket #5048: ticket5048.diff
File ticket5048.diff, 2.7 KB (added by , 17 years ago) |
---|
-
django/template/__init__.py
678 678 else: 679 679 try: # method call (assuming no args required) 680 680 current = current() 681 except TypeError: # arguments *were* required 682 # GOTCHA: This will also catch any TypeError 683 # raised in the function itself. 684 current = settings.TEMPLATE_STRING_IF_INVALID # invalid method call 681 except TypeError: 682 from sys import exc_info 683 from traceback import extract_tb 684 exc = exc_info() 685 if len(extract_tb(exc[-1], 2)) == 1: 686 # invalid method call, args *were* required 687 current = settings.TEMPLATE_STRING_IF_INVALID 688 else: 689 # TypeError was raised from within the function itself 690 raise 685 691 except Exception, e: 686 692 if getattr(e, 'silent_variable_failure', False): 687 693 current = settings.TEMPLATE_STRING_IF_INVALID 688 694 else: 689 695 raise 690 except (TypeError, AttributeError):696 except AttributeError: 691 697 try: # list-index lookup 692 698 current = current[int(bits[0])] 693 699 except (IndexError, # list index out of range -
tests/regressiontests/templates/tests.py
68 68 69 69 def method4(self): 70 70 raise SomeOtherException 71 72 def method5(self): 73 raise TypeError 71 74 72 75 class OtherClass: 73 76 def method(self): … … 189 192 # Embedded newlines make it not-a-tag. 190 193 'basic-syntax24': ("{{ moo\n }}", {}, "{{ moo\n }}"), 191 194 195 # Allow TypeError exceptions to propagate 196 'basic-syntax25': ("{{ var.method5 }}", {"var": SomeClass()}, TypeError), 197 192 198 # List-index syntax allows a template to access a certain item of a subscriptable object. 193 199 'list-index01': ("{{ var.1 }}", {"var": ["first item", "second item"]}, "second item"), 194 200