Skip to content

python3.11.9:UnicodeEncodeError: 'utf-8' codec can't encode characters in position 40-42: surrogates not allowed #117966

Closed
@awais786

Description

@awais786

Bug report

Bug description:

Bug Report

My test suit is failing 2 tests on python3.11.9. These are working fine on 3.11.7 and 3.11.8.

UnicodeEncodeError: 'utf-8' codec can't encode characters in position 40-42: surrogates not allowed

.tox/django42/lib/python3.11/site-packages/django/core/mail/message.py:168: in set_payload
    has_long_lines = any(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

.0 = <list_iterator object at 0x7fe402eaf730>

    has_long_lines = any(
>       len(line.encode()) > RFC5322_EMAIL_LINE_LENGTH_LIMIT
        for line in payload.splitlines()
    )
E   UnicodeEncodeError: 'utf-8' codec can't encode characters in position 40-42: surrogates not allowed

I did't find any thing in release notes.

CPython versions tested on:

3.11

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions