BUG: incorrect use of hasattr()