self.visit(node.arg, frame)
self.write(']')
return
- try:
- const = node.arg.as_const()
- have_const = True
- except nodes.Impossible:
- have_const = False
self.write('environment.subscribe(')
self.visit(node.node, frame)
self.write(', ')
- if have_const:
- self.write(repr(const))
- else:
- self.visit(node.arg, frame)
+ self.visit(node.arg, frame)
self.write(')')
def visit_Slice(self, node, frame):
"""Get an item or attribute of an object."""
if isinstance(argument, basestring):
try:
- return getattr(obj, str(argument))
- except (AttributeError, UnicodeError):
+ attr = str(argument)
+ except:
pass
+ else:
+ try:
+ return getattr(obj, attr)
+ except AttributeError:
+ pass
try:
return obj[argument]
except (TypeError, LookupError):
is_unsafe = False
if isinstance(argument, basestring):
try:
- value = getattr(obj, str(argument))
- except (AttributeError, UnicodeError):
+ attr = str(argument)
+ except:
pass
else:
- if self.is_safe_attribute(obj, argument, value):
- return value
- is_unsafe = True
+ try:
+ value = getattr(obj, attr)
+ except AttributeError:
+ pass
+ else:
+ if self.is_safe_attribute(obj, argument, value):
+ return value
+ is_unsafe = True
try:
return obj[argument]
except (TypeError, LookupError):