Created
June 26, 2011 11:51
-
-
Save ssbarnea/1047551 to your computer and use it in GitHub Desktop.
python-bug-12398
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
""" | |
This code works with Python 2.6 but fails on Python 2.7 | |
""" | |
import httplib, urllib2 | |
params = b'\x40\x00\x01\x02\xFF' | |
url = unicode("http://posttestserver.com/post.php") | |
req = urllib2.Request(url, data=params) | |
urllib2.urlopen(req) |
url can't contain non-ascii characters that are not percent-encoded (rfc3986) therefore the correct fix is to never use unicode
for urls. In this case url = url.encode('ascii')
is enough.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Workaround for this issue: