So the reason this `ImportError`s is it generates the code and then `exec`s it.  During the `exec` it tries to run `from invalid import fail` which triggers the import error.  Yeah I scratched my head about this a lot too.