def _validate_fname(fname):
msg = "<STR_LIT>"<EOL>if not isinstance(fname, str):<EOL><INDENT>raise RuntimeError(msg)<EOL><DEDENT>try:<EOL><INDENT>if not os.path.exists(fname):<EOL><INDENT>os.access(fname, os.W_OK)<EOL><DEDENT><DEDENT>except (TypeError, ValueError):  <EOL><INDENT>raise RuntimeError(msg)<EOL><DEDENT>
Validate that a string is a valid file name.