Didn't look in detail, but shouldn't that read `if arg and isinstance() [...]`?