Changing exceptions to work with older versions of python (2.2 or newer)