diff --git a/docs/client_advanced.rst b/docs/client_advanced.rst index 1d3e958d8d9..e8f016a96f0 100644 --- a/docs/client_advanced.rst +++ b/docs/client_advanced.rst @@ -645,15 +645,15 @@ on this. Character Set Detection ----------------------- -If you encounter a :exc:`UnicodeDecodeError` when using :meth:`ClientResponse.text()` -this may be because the response does not include the charset needed -to decode the body. +If you encounter an 'Automatic charset detection will be removed' warning +when using :meth:`ClientResponse.text()` this may be because the response +does not include the charset needed to decode the body. If you know the correct encoding for a request, you can simply specify the encoding as a parameter (e.g. ``resp.text("windows-1252")``). Alternatively, :class:`ClientSession` accepts a ``fallback_charset_resolver`` parameter which -can be used to introduce charset guessing functionality. When a charset is not found +can be used to reintroduce charset guessing functionality. When a charset is not found in the Content-Type header, this function will be called to get the charset encoding. For example, this can be used with the ``chardetng_py`` library.:: diff --git a/docs/client_reference.rst b/docs/client_reference.rst index ce05be837cd..d1d877255d4 100644 --- a/docs/client_reference.rst +++ b/docs/client_reference.rst @@ -52,7 +52,7 @@ The client session supports the context manager protocol for self closing. requote_redirect_url=False, \ trust_env=False, \ trace_configs=None, \ - fallback_charset_resolver=lambda r, b: "utf-8") + fallback_charset_resolver=_chardet_resolver) The class for creating client sessions and making requests. @@ -207,7 +207,9 @@ The client session supports the context manager protocol for self closing. the encoding parameter to :meth:`bytes.decode()`. This function will be called when the charset is not known (e.g. not specified in the - Content-Type header). The default function simply defaults to ``utf-8``. + Content-Type header). The default function in 3.8.6 calls chardetng + or charset-normaliser. In 3.9+ this be replaced with a function that + simply defaults to ``utf-8``. .. versionadded:: 3.8.6 @@ -1422,8 +1424,6 @@ Response object (default). - :raises: :exc:`UnicodeDecodeError` if decoding fails. See also - :meth:`get_encoding`. .. note:: @@ -1438,6 +1438,7 @@ Response object .. method:: json(*, encoding=None, loads=json.loads, \ content_type='application/json') + :async: Read response's body as *JSON*, return :class:`dict` using specified *encoding* and *loader*. If data is not still available