def _unpickle_channel(raw):
try:<EOL><INDENT>return pickle.loads(raw)<EOL><DEDENT>except (ValueError, pickle.UnpicklingError, EOFError, TypeError,<EOL>IndexError) as exc:<EOL><INDENT>if isinstance(raw, bytes):<EOL><INDENT>raw = raw.decode('<STR_LIT:utf-8>')<EOL><DEDENT>try:  <EOL><INDENT>Channel.MATCH.match(raw)<EOL><DEDENT>except ValueError:<EOL><INDENT>raise exc<EOL><DEDENT>return raw<EOL><DEDENT>
Try and unpickle a channel with sensible error handling