Fix object comparison in Python 3