Support Ruby 1.8.7 which used IndexError instead of KeyError in newer versions.