on second thought that function is too restrictive it rejects io based file objects which are default in python3