Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamsorcerer authored Sep 9, 2023
1 parent cae5270 commit 59cf434
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
8 changes: 4 additions & 4 deletions docs/client_advanced.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.::

Expand Down
9 changes: 5 additions & 4 deletions docs/client_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -1422,8 +1424,6 @@ Response object
(default).


:raises: :exc:`UnicodeDecodeError` if decoding fails. See also
:meth:`get_encoding`.

.. note::

Expand All @@ -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
Expand Down

0 comments on commit 59cf434

Please sign in to comment.