Fix error in common.escape_query_for_python function