Fix a few urllib bugs (NameErrors).

Also directly import names from the various urllib submodules,
saves attribute lookup and is much cleaner.
This commit is contained in:
Georg Brandl 2008-07-01 19:56:00 +00:00
parent 1abcbf8e19
commit 13e89463e3
2 changed files with 125 additions and 126 deletions

View file

@ -416,11 +416,11 @@ def urlencode(query,doseq=0):
# urllib.parse.unquote('abc%20def') -> 'abc def'
# quote('abc def') -> 'abc%20def')
def toBytes(url):
"""toBytes(u"URL") --> 'URL'."""
def to_bytes(url):
"""to_bytes(u"URL") --> 'URL'."""
# Most URL schemes require ASCII. If that changes, the conversion
# can be relaxed.
# XXX get rid of toBytes()
# XXX get rid of to_bytes()
if isinstance(url, str):
try:
url = url.encode("ASCII").decode()