If the target nonland permanent is an illegal target by the time Turn into a Pumpkin tries to resolve, the spell won't resolve. You won't draw a card, and you won't create a Food if you spent three blue mana to cast the spell.