unicode is not defined anymore in Python3, however just switching the
order in the if branch is enough to the type checks unnecessary