fixed bug: empty buf for OSError -- must be bytes (not str)

(cherry picked from commit c07936d28300607a0546bc266bb186d81aaee335)