title: Python-3 Request parameter encoding error
body: <p>I have been working on a <code>django</code> project based upon <code>Python 3</code>. I am trying to incorporate <code>captcha</code>. I choosed <a href="https://github.com/praekelt/django-recaptcha" rel="nofollow">django-recaptcha</a> but unfortunately the package is not available for python3. So tried to tailor it for python3. I did some <code>2to3</code> stuff and made some changes as per need. Everything seems to work fine except the <code>url encoding for Request</code>.</p>
  
  <p>Following snippet yields <code>POST data should be bytes or an iterable of bytes. It cannot be of type str.</code> exception.</p>
  
  <pre><code>def encode_if_necessary(s):
      if isinstance(s, str):
          return s.encode('utf-8')
      return s
  
  params = urllib.parse.urlencode({
          'privatekey': encode_if_necessary(private_key),
          'remoteip':  encode_if_necessary(remoteip),
          'challenge':  encode_if_necessary(recaptcha_challenge_field),
          'response':  encode_if_necessary(recaptcha_response_field),
          })
  
  if use_ssl:
      verify_url = "https://%s/recaptcha/api/verify" % VERIFY_SERVER
  else:
      verify_url = "http://%s/recaptcha/api/verify" % VERIFY_SERVER
  
  request = urllib.request.Request(
      url= verify_url,
      data=params,
      headers={
          "Content-type": "application/x-www-form-urlencoded",
          "User-agent": "reCAPTCHA Python"
          }
      )
  
  httpresp = urllib.request.urlopen(request)
  </code></pre>
  
  <p>So I tried to encode the url and other stuff in <code>request</code>-</p>
  
  <pre><code>request = urllib.request.Request(
      url= encode_if_necessary(verify_url),
      data=params,
      headers={
          "Content-type": encode_if_necessary("application/x-www-form-urlencoded"),
          "User-agent": encode_if_necessary("reCAPTCHA Python")
          }
      )
  </code></pre>
  
  <p>But this yields <code>urlopen error unknown url type: b'http</code> exception.</p>
  
  <p>Does anyone know how to fix it? Any help is appreciated :).</p>