More idiomatic Python
FWIW, I'm not convinced whether the check is needed at all - but if it is there,
isinstance is the thing to use
As for not needing it at all: Duck typing would be enough - all we expect is a thing having an
.encode('utf-8') method which returns a bytes object. This could be a string, but it could (in theory) as well be some user-defined object.