When doing this I find it cleaner to use 

isinstance(stdout, six.binary_type)