>> +	if (PyUnicode_Check(ret) || PyBytes_Check(ret)) {
>
> This seems odd - why check for Unicode or Bytes if you're only going to
> accept unicode further down?

PyUnicode_FSConverter() actually works with bytes or unicode. This
check is to separate that case from a fileno() object or an integer
file descriptor.