[REG2.062] Issue 9865 - Crash on bogus import / circular reference

http://d.puremagic.com/issues/show_bug.cgi?id=9865

This is a regression caused by fixing issue 9514 (03b0cad6bdfe9646f0907ca3abb8d1ac65073192).