'Parses Python code.
Arguments:
python_code: The Python code to be parsed.
Returns:
The root node that was parsed, or None for SyntaxError.'

def parse_python_code(self, python_code, results):

    python_code = self._strip_file_encoding(python_code)
    try:
        return ast.parse(python_code)
    except SyntaxError as e:
        if (e.offset is None):
            expression = Expression(0)
        else:
            lines = StringLines(python_code)
            line_start_index = lines.line_number_to_start_index(e.lineno)
            expression = Expression((line_start_index + e.offset))
        results.violations.append(ExpressionRuleViolation(Rules.python_parse_error, expression))
        return None
