Use hasattr instead of try/except (refs 4ea1a9c)