def _format_arg(arg):
<EOL>if not (_isexception(arg) or isinstance(arg, (str, tuple, list))):<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>if isinstance(arg, (tuple, list)) and ((not arg) or (len(arg) > <NUM_LIT:2>)):<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>if isinstance(arg, str) and (not arg):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if isinstance(arg, str):<EOL><INDENT>return {"<STR_LIT>": arg, "<STR_LIT:type>": RuntimeError}<EOL><DEDENT>if _isexception(arg):<EOL><INDENT>return {"<STR_LIT>": "<STR_LIT>", "<STR_LIT:type>": arg}<EOL><DEDENT>if (len(arg) == <NUM_LIT:1>) and (not isinstance(arg[<NUM_LIT:0>], str)) and (not _isexception(arg[<NUM_LIT:0>])):<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>if (len(arg) == <NUM_LIT:2>) and (<EOL>not (<EOL>(isinstance(arg[<NUM_LIT:0>], str) and _isexception(arg[<NUM_LIT:1>]))<EOL>or (isinstance(arg[<NUM_LIT:1>], str) and _isexception(arg[<NUM_LIT:0>]))<EOL>)<EOL>):<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>if (len(arg) == <NUM_LIT:1>) and isinstance(arg[<NUM_LIT:0>], str) and (not arg[<NUM_LIT:0>]):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if (len(arg) == <NUM_LIT:2>) and (<EOL>(isinstance(arg[<NUM_LIT:0>], str) and (not arg[<NUM_LIT:0>]))<EOL>or (isinstance(arg[<NUM_LIT:1>], str) and (not arg[<NUM_LIT:1>]))<EOL>):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if len(arg) == <NUM_LIT:1>:<EOL><INDENT>return {<EOL>"<STR_LIT>": (<EOL>arg[<NUM_LIT:0>]<EOL>if isinstance(arg[<NUM_LIT:0>], str)<EOL>else "<STR_LIT>"<EOL>),<EOL>"<STR_LIT:type>": arg[<NUM_LIT:0>] if _isexception(arg[<NUM_LIT:0>]) else RuntimeError,<EOL>}<EOL><DEDENT>return {<EOL>"<STR_LIT>": arg[<NUM_LIT:0>] if isinstance(arg[<NUM_LIT:0>], str) else arg[<NUM_LIT:1>],<EOL>"<STR_LIT:type>": arg[<NUM_LIT:0>] if _isexception(arg[<NUM_LIT:0>]) else arg[<NUM_LIT:1>],<EOL>}<EOL>
Validate one exception specification contract tuple/list.