read. If set, then throws a :exc:`ValueError` if there are more than
*max_num_fields* fields read.
- The optional argument *separator* is the symbol to use for separating the query arguments. It defaults to `&`.
+ The optional argument *separator* is the symbol to use for separating the
+ query arguments. It defaults to ``&``.
Use the :func:`urllib.parse.urlencode` function (with the ``doseq``
parameter set to ``True``) to convert such dictionaries into query
Added *max_num_fields* parameter.
.. versionchanged:: 3.10
- Added *separator* parameter with the default value of `&`. Python versions earlier than Python 3.10 allowed using both ";" and "&" as
- query parameter separator. This has been changed to allow only a single separator key, with "&" as the default separator.
+ Added *separator* parameter with the default value of ``&``. Python
+ versions earlier than Python 3.10 allowed using both ``;`` and ``&`` as
+ query parameter separator. This has been changed to allow only a single
+ separator key, with ``&`` as the default separator.
.. function:: parse_qsl(qs, keep_blank_values=False, strict_parsing=False, encoding='utf-8', errors='replace', max_num_fields=None, separator='&')
read. If set, then throws a :exc:`ValueError` if there are more than
*max_num_fields* fields read.
- The optional argument *separator* is the symbol to use for separating the query arguments. It defaults to `&`.
+ The optional argument *separator* is the symbol to use for separating the
+ query arguments. It defaults to ``&``.
Use the :func:`urllib.parse.urlencode` function to convert such lists of pairs into
query strings.
Added *max_num_fields* parameter.
.. versionchanged:: 3.10
- Added *separator* parameter with the default value of `&`. Python versions earlier than Python 3.10 allowed using both ";" and "&" as
- query parameter separator. This has been changed to allow only a single separator key, with "&" as the default separator.
+ Added *separator* parameter with the default value of ``&``. Python
+ versions earlier than Python 3.10 allowed using both ``;`` and ``&`` as
+ query parameter separator. This has been changed to allow only a single
+ separator key, with ``&`` as the default separator.
.. function:: urlunparse(parts)
Notable changes in Python 3.6.13
================================
-Earlier Python versions allowed using both ";" and "&" as
+Earlier Python versions allowed using both ``;`` and ``&`` as
query parameter separators in :func:`urllib.parse.parse_qs` and
:func:`urllib.parse.parse_qsl`. Due to security concerns, and to conform with
newer W3C recommendations, this has been changed to allow only a single
-separator key, with "&" as the default. This change also affects
+separator key, with ``&`` as the default. This change also affects
:func:`cgi.parse` and :func:`cgi.parse_multipart` as they use the affected
functions internally. For more details, please see their respective
documentation.
Notable changes in Python 3.8.8
===============================
-Earlier Python versions allowed using both ";" and "&" as
+Earlier Python versions allowed using both ``;`` and ``&`` as
query parameter separators in :func:`urllib.parse.parse_qs` and
:func:`urllib.parse.parse_qsl`. Due to security concerns, and to conform with
newer W3C recommendations, this has been changed to allow only a single
-separator key, with "&" as the default. This change also affects
+separator key, with ``&`` as the default. This change also affects
:func:`cgi.parse` and :func:`cgi.parse_multipart` as they use the affected
functions internally. For more details, please see their respective
documentation.
urllib.parse
------------
-Earlier Python versions allowed using both ";" and "&" as
+Earlier Python versions allowed using both ``;`` and ``&`` as
query parameter separators in :func:`urllib.parse.parse_qs` and
:func:`urllib.parse.parse_qsl`. Due to security concerns, and to conform with
newer W3C recommendations, this has been changed to allow only a single
-separator key, with "&" as the default. This change also affects
+separator key, with ``&`` as the default. This change also affects
:func:`cgi.parse` and :func:`cgi.parse_multipart` as they use the affected
functions internally. For more details, please see their respective
documentation.
"""
qs, _coerce_result = _coerce_args(qs)
- if not separator or (not isinstance(separator, str)
- and not isinstance(separator, bytes)):
+ if not separator or (not isinstance(separator, (str, bytes))):
raise ValueError("Separator must be of type string or bytes.")
# If max_num_fields is defined then check that the number of fields