fix has_key for python 3 compatibility