Use isinstance instead of type() == x

This is a follow-up to a discussion in #1422.  If this change passes Travis, I think it's obviously preferable (just not sure if it is the way it is for a reason).