summaryrefslogtreecommitdiffstats
path: root/Lib/urllib
diff options
context:
space:
mode:
authorSenthil Kumaran <skumaran@gatech.edu>2017-04-05 04:19:43 (GMT)
committerGitHub <noreply@github.com>2017-04-05 04:19:43 (GMT)
commit257b980b316a5206ecf6c23b958e2b7c4df4f3de (patch)
tree740cc98c682ee552d4822600f37b4dc17ceff93e /Lib/urllib
parentf78b119364b521307237a1484ba5f43f42300898 (diff)
downloadcpython-257b980b316a5206ecf6c23b958e2b7c4df4f3de.zip
cpython-257b980b316a5206ecf6c23b958e2b7c4df4f3de.tar.gz
cpython-257b980b316a5206ecf6c23b958e2b7c4df4f3de.tar.bz2
correct parse_qs and parse_qsl test case descriptions. (#968)
* correct parse_qs and parse_qsl test case descriptions.
Diffstat (limited to 'Lib/urllib')
-rw-r--r--Lib/urllib/parse.py30
1 files changed, 17 insertions, 13 deletions
diff --git a/Lib/urllib/parse.py b/Lib/urllib/parse.py
index f3a309a..5d33159 100644
--- a/Lib/urllib/parse.py
+++ b/Lib/urllib/parse.py
@@ -612,6 +612,7 @@ def unquote(string, encoding='utf-8', errors='replace'):
append(bits[i + 1])
return ''.join(res)
+
def parse_qs(qs, keep_blank_values=False, strict_parsing=False,
encoding='utf-8', errors='replace'):
"""Parse a query given as a string argument.
@@ -633,6 +634,8 @@ def parse_qs(qs, keep_blank_values=False, strict_parsing=False,
encoding and errors: specify how to decode percent-encoded sequences
into Unicode characters, as accepted by the bytes.decode() method.
+
+ Returns a dictionary.
"""
parsed_result = {}
pairs = parse_qsl(qs, keep_blank_values, strict_parsing,
@@ -644,28 +647,29 @@ def parse_qs(qs, keep_blank_values=False, strict_parsing=False,
parsed_result[name] = [value]
return parsed_result
+
def parse_qsl(qs, keep_blank_values=False, strict_parsing=False,
encoding='utf-8', errors='replace'):
"""Parse a query given as a string argument.
- Arguments:
+ Arguments:
- qs: percent-encoded query string to be parsed
+ qs: percent-encoded query string to be parsed
- keep_blank_values: flag indicating whether blank values in
- percent-encoded queries should be treated as blank strings. A
- true value indicates that blanks should be retained as blank
- strings. The default false value indicates that blank values
- are to be ignored and treated as if they were not included.
+ keep_blank_values: flag indicating whether blank values in
+ percent-encoded queries should be treated as blank strings.
+ A true value indicates that blanks should be retained as blank
+ strings. The default false value indicates that blank values
+ are to be ignored and treated as if they were not included.
- strict_parsing: flag indicating what to do with parsing errors. If
- false (the default), errors are silently ignored. If true,
- errors raise a ValueError exception.
+ strict_parsing: flag indicating what to do with parsing errors. If
+ false (the default), errors are silently ignored. If true,
+ errors raise a ValueError exception.
- encoding and errors: specify how to decode percent-encoded sequences
- into Unicode characters, as accepted by the bytes.decode() method.
+ encoding and errors: specify how to decode percent-encoded sequences
+ into Unicode characters, as accepted by the bytes.decode() method.
- Returns a list, as G-d intended.
+ Returns a list, as G-d intended.
"""
qs, _coerce_result = _coerce_args(qs)
pairs = [s2 for s1 in qs.split('&') for s2 in s1.split(';')]