def fix_missing_locations(node):
 def _fix(node, lineno, col_offset):
  if ('lineno' in node._attributes):
   if (not hasattr(node, 'lineno')):
    node.lineno = lineno
   else:
    lineno = node.lineno
  if ('col_offset' in node._attributes):
   if (not hasattr(node, 'col_offset')):
    node.col_offset = col_offset
   else:
    col_offset = node.col_offset
  for child in iter_child_nodes(node):
   _fix(child, lineno, col_offset)
 _fix(node, 1, 0)
 return node

def fix_missing_locations ( node ) : def _fix ( node , lineno , col_offset ) : if ( 'lineno' in node . _attributes ) : if ( not hasattr ( node , 'lineno' ) ) : node . lineno = lineno else : lineno = node . lineno if ( 'col_offset' in node . _attributes ) : if ( not hasattr ( node , 'col_offset' ) ) : node . col_offset = col_offset else : col_offset = node . col_offset for child in iter_child_nodes ( node ) : _fix ( child , lineno , col_offset ) _fix ( node , 1 , 0 ) return node
some nodes require a line number and the column offset .