Repository: ipython/ipython

Issue:
'Nicer' import failure messages cause another error on Python 3
#5991 aimed to improve the error message when there was an ImportError from loading jsonschema. Unfortunately, it blows up on Python 3, because the 'message' attribute is now 'msg':

```
Traceback (most recent call last):
  File "/Users/minrk/env/sp33/lib/python3.3/site-packages/IPython/nbformat/validator.py", line 6, in <module>
    from jsonschema import SchemaError
ImportError: No module named 'jsonschema'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/unittest/case.py", line 384, in _executeTestPart
    function()
  File "/Users/minrk/env/sp33/lib/python3.3/site-packages/nose/failure.py", line 39, in runTest
    raise self.exc_val.with_traceback(self.tb)
  File "/Users/minrk/env/sp33/lib/python3.3/site-packages/nose/loader.py", line 411, in loadTestsFromName
    addr.filename, addr.module)
  File "/Users/minrk/env/sp33/lib/python3.3/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/Users/minrk/env/sp33/lib/python3.3/site-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/Users/minrk/env/sp33/lib/python3.3/imp.py", line 180, in load_module
    return load_source(name, filename, file)
  File "/Users/minrk/env/sp33/lib/python3.3/imp.py", line 119, in load_source
    _LoadSourceCompatibility(name, pathname, file).load_module(name)
  File "<frozen importlib._bootstrap>", line 584, in _check_name_wrapper
  File "<frozen importlib._bootstrap>", line 1022, in load_module
  File "<frozen importlib._bootstrap>", line 1003, in load_module
  File "<frozen importlib._bootstrap>", line 560, in module_for_loader_wrapper
  File "<frozen importlib._bootstrap>", line 868, in _load_module
  File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
  File "/Users/minrk/env/sp33/lib/python3.3/site-packages/IPython/terminal/tests/test_help.py", line 40, in <module>
    @skip_without('IPython.nbformat.current')  # Requires jsonschema to be installed
  File "/Users/minrk/env/sp33/lib/python3.3/site-packages/IPython/testing/decorators.py", line 337, in <lambda>
    skip_without = lambda mod: skipif(module_not_available(mod), "This test requires %s" % mod)
  File "/Users/minrk/env/sp33/lib/python3.3/site-packages/IPython/testing/decorators.py", line 284, in module_not_available
    mod = __import__(module)
  File "/Users/minrk/env/sp33/lib/python3.3/site-packages/IPython/nbformat/current.py", line 38, in <module>
    from .validator import validate
  File "/Users/minrk/env/sp33/lib/python3.3/site-packages/IPython/nbformat/validator.py", line 15, in <module>
    raise ImportError(e.message + verbose_msg)
AttributeError: 'ImportError' object has no attribute 'message'
```



Discussion:

Resolving patch:
diff --git a/IPython/nbformat/validator.py b/IPython/nbformat/validator.py
--- a/IPython/nbformat/validator.py
+++ b/IPython/nbformat/validator.py
@@ -12,7 +12,7 @@
     
     Please install it first.
     """
-    raise ImportError(e.message + verbose_msg)
+    raise ImportError(str(e) + verbose_msg)
 
 try:
     import jsonpointer as jsonpointer
@@ -23,7 +23,7 @@
     
     Please install it first.
     """
-    raise ImportError(e.message + verbose_msg)
+    raise ImportError(str(e) + verbose_msg)
 
 from IPython.utils.py3compat import iteritems
 


Test patch: