Changed the exception to something portable (Py2 vs Py3).