summaryrefslogtreecommitdiffstats
path: root/Doc/howto/urllib2.rst
diff options
context:
space:
mode:
authorSenthil Kumaran <senthil@uthcode.com>2012-03-15 01:11:46 (GMT)
committerSenthil Kumaran <senthil@uthcode.com>2012-03-15 01:11:46 (GMT)
commit7596aeaba7944fd8615b061c578a8ff284b40698 (patch)
tree7aa65d33053679c0d6b45db832ce34de7633dfa0 /Doc/howto/urllib2.rst
parent3d7c878fe370e59b142bac9bc32c67b4ac9d949e (diff)
parent87684e6eeab154bf7d8775b767e2558ddf659745 (diff)
downloadcpython-7596aeaba7944fd8615b061c578a8ff284b40698.zip
cpython-7596aeaba7944fd8615b061c578a8ff284b40698.tar.gz
cpython-7596aeaba7944fd8615b061c578a8ff284b40698.tar.bz2
cpython:Fix the wrong urllib exampls which use str for POST data. Closes Issue11261
Diffstat (limited to 'Doc/howto/urllib2.rst')
-rw-r--r--Doc/howto/urllib2.rst4
1 files changed, 3 insertions, 1 deletions
diff --git a/Doc/howto/urllib2.rst b/Doc/howto/urllib2.rst
index 058cf96..3ac8312 100644
--- a/Doc/howto/urllib2.rst
+++ b/Doc/howto/urllib2.rst
@@ -115,6 +115,7 @@ library. ::
'language' : 'Python' }
data = urllib.parse.urlencode(values)
+ data = data.encode('utf-8') # data should be bytes
req = urllib.request.Request(url, data)
response = urllib.request.urlopen(req)
the_page = response.read()
@@ -179,7 +180,8 @@ Explorer [#]_. ::
'language' : 'Python' }
headers = { 'User-Agent' : user_agent }
- data = urllib.parse.urlencode(values)
+ data = urllib.parse.urlencode(values)
+ data = data.encode('utf-8')
req = urllib.request.Request(url, data, headers)
response = urllib.request.urlopen(req)
the_page = response.read()