Skip to content
Myr

subscribe doesn't eat up unicode errors any longer

Before adoption: this commit came in with the history the project adopted, so no landing records it.

--HG-- branch : trunk

authored by Armin Ronacher · committed by Armin Ronacher · parent 67fdddf · Browse files · 3 files+18 added−16 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+18 added−16 removed

  • other:+18 added−16 removed

3 files+18 added−16 removed

modified:jinja2/compiler.py+1 added-9 removed
1295 unmodified lines
1296 self.write('[')1297 self.visit(node.arg, frame)1298 self.write(']')1299 return1300 try:1301 const = node.arg.as_const()1302 have_const = True1303 except nodes.Impossible:1304 have_const = False1300 self.write('environment.subscribe(')1301 self.visit(node.node, frame)1302 self.write(', ')1308 if have_const:1309 self.write(repr(const))1310 else:1311 self.visit(node.arg, frame)1303 self.visit(node.arg, frame)1304 self.write(')')13051306 def visit_Slice(self, node, frame):1307 if node.start is not None:
67 unmodified lines
modified:jinja2/environment.py+7 added-2 removed
278 unmodified lines
279 def subscribe(self, obj, argument):280 """Get an item or attribute of an object."""281 if isinstance(argument, basestring):282 try:283 return getattr(obj, str(argument))284 except (AttributeError, UnicodeError):283 attr = str(argument)284 except:285 pass286 else:287 try:288 return getattr(obj, attr)289 except AttributeError:290 pass291 try:292 return obj[argument]293 except (TypeError, LookupError):294 return self.undefined(obj=obj, name=argument)
388 unmodified lines
modified:jinja2/sandbox.py+10 added-5 removed
118 unmodified lines
119 """Subscribe an object from sandboxed code."""120 is_unsafe = False121 if isinstance(argument, basestring):122 try:123 value = getattr(obj, str(argument))124 except (AttributeError, UnicodeError):123 attr = str(argument)124 except:125 pass126 else:127 try:128 value = getattr(obj, attr)129 except AttributeError:130 pass131 else:127 if self.is_safe_attribute(obj, argument, value):128 return value129 is_unsafe = True132 if self.is_safe_attribute(obj, argument, value):133 return value134 is_unsafe = True135 try:136 return obj[argument]137 except (TypeError, LookupError):138 if is_unsafe:
14 unmodified lines