Fixed comparing of queries in Python 3.3