Use hasattr for version compatiable.