Fix smart attribute comparation

This is a patch for github issue #1040 (just turned the attached patch into a pull request)