Skip to content

atspienum: Also catch TypeErrors when casting

Niels De Graef requested to merge nielsdg/atspienum-typeerror into master

In the __eq__ we try to broadly compare any object towards the enum by casting it to int and comparing the numbers. In some cases, casting to int of course doesn't make sense, so there's an except ValueError case to automatically return false without propagating that exception.

The problem now is that when trying to cast an object to an int doesn't return a ValueError, but a TypeError instead, so this still throws an uncaught exception. This seems to be happening when comparing in practice when comparing AtSpiEnum with a Accessible object.

Fix this by also catching a TypeError.

Merge request reports