Isinstance basestring
This replaces str with basestring in all isinstance() checks, of which there is a disturbingly large number.
Perhaps we should handle the filename/file-object distinction centrally when opening files to remove some 100+ identical isinstance() checks.