Fix hacking.py to handle 'cannot import x'

Fix missingImport logic to handle a module that cannot be imported, due
to a missing dependant module.

Due to the nature of this bug doctests cannot cover it.

Fix bug 1133103

Change-Id: Ia067bacc125b67e2d9e0cfc72495e4f13a8648ad
Merge "Fix hacking.py to handle 'cannot import x'"