Exceptions with Accept-Type application/json will return JSON error.

'basestring' is not defined in Py3k.  Use the constant defined in 'compat.py'.