diff options
| author | Senthil Kumaran <senthil@uthcode.com> | 2012-03-14 18:11:46 -0700 |
|---|---|---|
| committer | Senthil Kumaran <senthil@uthcode.com> | 2012-03-14 18:11:46 -0700 |
| commit | 7596aeaba7944fd8615b061c578a8ff284b40698 (patch) | |
| tree | 7aa65d33053679c0d6b45db832ce34de7633dfa0 /Doc/howto | |
| parent | 3d7c878fe370e59b142bac9bc32c67b4ac9d949e (diff) | |
| parent | 87684e6eeab154bf7d8775b767e2558ddf659745 (diff) | |
| download | cpython-git-7596aeaba7944fd8615b061c578a8ff284b40698.tar.gz | |
cpython:Fix the wrong urllib exampls which use str for POST data. Closes Issue11261
Diffstat (limited to 'Doc/howto')
| -rw-r--r-- | Doc/howto/urllib2.rst | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Doc/howto/urllib2.rst b/Doc/howto/urllib2.rst index 058cf967ec..3ac8312e9c 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() |
