Skip to content

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb5 in position 1: invalid start byte #11362

@vitoriadaamasceno

Description

@vitoriadaamasceno

Describe the bug

When using errors.text(errors="backslashreplace") it doesn't find the error parameter.
I'm using version aiohttp==3.12.15

To Reproduce

When executing a url that contains gif or image that are not in UTF-8 standard it generates the error, when trying to ignore or replace with the errors parameter it does not allow

Expected behavior

When using ignore it, it will ignore these characters

Logs/tracebacks

body = await response.text()
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 733, in text
    return self._body.decode(encoding, errors=errors)  # type: ignore[union-attr]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb5 in position 1: invalid start byte

Python Version

3.11.9

aiohttp Version

aiohttp==3.12.15

multidict Version

Name: multidict
Version: 6.0.5
Summary: multidict implementation
Home-page: https://github.com/aio-libs/multidict
Author: Andrew Svetlov
Author-email: andrew.svetlov@gmail.com
License: Apache 2
Requires: 
Required-by: aiohttp, yarl

propcache Version

Name: propcache
Version: 0.3.1
Summary: Accelerated property cache
Home-page: https://github.com/aio-libs/propcache
Author: Andrew Svetlov
Author-email: andrew.svetlov@gmail.com
License: Apache-2.0
Requires: 
Required-by: aiohttp, yarl

yarl Version

Name: yarl
Version: 1.20.0
Summary: Yet another URL library
Home-page: https://github.com/aio-libs/yarl
Author: Andrew Svetlov
Author-email: andrew.svetlov@gmail.com
License: Apache-2.0
Requires: idna, multidict, propcache
Required-by: aiohttp

OS

Linux

Related component

Client

Additional context

No response

Code of Conduct

  • I agree to follow the aio-libs Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugneeds-infoIssue is lacking sufficient information and will be closed if not provided

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions