diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2009-03-26 14:49:26 (GMT) |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2009-03-26 14:49:26 (GMT) |
commit | a4de60a1deca08b26269dc39505bddae0d9cf267 (patch) | |
tree | bb0df070e1ade37a5a6086ae4d34d7ead6e1d97d /Lib/urllib/parse.py | |
parent | 663fffa4e2d4e4eb4955bfcedfe09453899d1210 (diff) | |
download | cpython-a4de60a1deca08b26269dc39505bddae0d9cf267.zip cpython-a4de60a1deca08b26269dc39505bddae0d9cf267.tar.gz cpython-a4de60a1deca08b26269dc39505bddae0d9cf267.tar.bz2 |
Whitespace normalization.
Diffstat (limited to 'Lib/urllib/parse.py')
-rw-r--r-- | Lib/urllib/parse.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/Lib/urllib/parse.py b/Lib/urllib/parse.py index 9dd8981..0771db9 100644 --- a/Lib/urllib/parse.py +++ b/Lib/urllib/parse.py @@ -504,7 +504,7 @@ def quote_from_bytes(bs, safe='/'): _safe_quoters[cachekey] = quoter return ''.join(map(quoter.__getitem__, bs)) -def urlencode(query,doseq=0): +def urlencode(query, doseq=0): """Encode a sequence of two-element tuples or dictionary into a URL query string. If any values in the query arg are sequences and doseq is true, each @@ -515,7 +515,7 @@ def urlencode(query,doseq=0): input. """ - if hasattr(query,"items"): + if hasattr(query, "items"): # mapping objects query = query.items() else: @@ -531,8 +531,9 @@ def urlencode(query,doseq=0): # allowed empty dicts that type of behavior probably should be # preserved for consistency except TypeError: - ty,va,tb = sys.exc_info() - raise TypeError("not a valid non-string sequence or mapping object").with_traceback(tb) + ty, va, tb = sys.exc_info() + raise TypeError("not a valid non-string sequence " + "or mapping object").with_traceback(tb) l = [] if not doseq: @@ -551,7 +552,7 @@ def urlencode(query,doseq=0): # is there a reasonable way to convert to ASCII? # encode generates a string, but "replace" or "ignore" # lose information and "strict" can raise UnicodeError - v = quote_plus(v.encode("ASCII","replace")) + v = quote_plus(v.encode("ASCII", "replace")) l.append(k + '=' + v) else: try: |