diff options
author | Senthil Kumaran <orsenthil@gmail.com> | 2011-02-11 11:25:47 (GMT) |
---|---|---|
committer | Senthil Kumaran <orsenthil@gmail.com> | 2011-02-11 11:25:47 (GMT) |
commit | 2933312fe71f15d127009c872cd1e5f98a993999 (patch) | |
tree | 03f8751cfc59abde72fc3379ebfd14a82d6718d0 /Lib/urllib/request.py | |
parent | 44028d866336743dc2e3d62daa02d4a8ea318d81 (diff) | |
download | cpython-2933312fe71f15d127009c872cd1e5f98a993999.zip cpython-2933312fe71f15d127009c872cd1e5f98a993999.tar.gz cpython-2933312fe71f15d127009c872cd1e5f98a993999.tar.bz2 |
Fixed issue11082 - Reject str for POST data with a TypeError. Document the need to explicitly encode to bytes when using urlencode.
Diffstat (limited to 'Lib/urllib/request.py')
-rw-r--r-- | Lib/urllib/request.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py index a188393..dfdbdec 100644 --- a/Lib/urllib/request.py +++ b/Lib/urllib/request.py @@ -1048,6 +1048,9 @@ class AbstractHTTPHandler(BaseHandler): if request.data is not None: # POST data = request.data + if isinstance(data, str): + raise TypeError("POST data should be bytes" + " or an iterable of bytes. It cannot be str.") if not request.has_header('Content-type'): request.add_unredirected_header( 'Content-type', |