Don't try to loop over None. fix #2268