Shouldn't this check against `basestring` or `py3compat.string_types`? Are we sure it's OK to check only pure `str`?