Issue #15972: Fix error messages when os functions expecting a file name or
file descriptor receive the incorrect type.