[core] Guard against objects with no __name__.

- Fixes issue #313.