code: def unquote_to_bytes(string):
      
      # Note: strings are encoded as UTF-8. This is only an issue if it contains
      # unescaped non-ASCII characters, which URIs should not.
      if not string:
          # Is it a string-like object?
          string.split
          return bytes(b'')
      if isinstance(string, str):
          string = string.encode('utf-8')
      ### For Python-Future:
      # It is already a byte-string object, but force it to be newbytes here on
      # Py2:
      string = bytes(string)
      ###
      bits = string.split(b'%')
      if len(bits) == 1:
          return string
      res = [bits[0]]
      append = res.append
      for item in bits[1:]:
          try:
              append(_hextobyte[item[:2]])
              append(item[2:])
          except KeyError:
              append(b'%')
              append(item)
      return bytes(b'').join(res)
docs: unquote_to_bytes('abc%20def') -> b'abc def'.