code: def parse_close(data):
      '''Parse the body of a close :class:`Frame`.
  
      Returns a tuple (``code``, ``reason``) if successful otherwise
      raise :class:`.ProtocolError`.
      '''
      length = len(data)
      if length == 0:
          return 1005, ''
      elif length == 1:
          raise ProtocolError("Close frame too short")
      else:
          code, = unpack('!H', data[:2])
          if not (code in CLOSE_CODES or 3000 <= code < 5000):
              raise ProtocolError("Invalid status code for websocket")
          reason = data[2:].decode('utf-8')
          return code, reasof parse_close(data):
      '''Parse the body of a close :class:`Frame`.
  
      Returns a tuple (``code``, ``reason``) if successful otherwise
      raise :class:`.ProtocolError`.
      '''
      length = len(data)
      if length == 0:
          return 1005, ''
      elif length == 1:
          raise ProtocolError("Close frame too short")
      else:
          code, = unpack('!H', data[:2])
          if not (code in CLOSE_CODES or 3000 <= code < 5000):
              raise ProtocolError("Invalid status code for websocket")
          reason = data[2:].decode('utf-8')
          return code, reason
docs: Parse the body of a close :class:`Frame`.
  
      Returns a tuple (``code``, ``reason``) if successful otherwise
      raise :class:`.ProtocolError`.