[New-bugs-announce] [issue25545] email.message.get_payload returns wrong encoding

Christian Tanzer report at bugs.python.org
Tue Nov 3 09:43:30 EST 2015


New submission from Christian Tanzer:

For an email message with `Content-type: text/plain; charset=utf-8`, in Python 3.5, get_payload returns a bytes object encoded with `latin-1`. Python 2.7 returns a str object encoded with `utf-8` as expected.

Running the attached test script `email_get_payload__test.py`  with Python 2.7 and 3.5 shows the difference.

Python 2.7::

    2.7.10.final.0 *** utf8 ***
    From: Christian Tanzer <tanzer at swing.co.at>
    To: Christian Tanzer <tanzer at swing.co.at>
    Content-type: text/plain; charset=utf-8


    Sehr geehrte Damen und Herren,

    ...

    Danke und mit freundlichen Grüssen,

    --
    Christian Tanzer                                    http://www.c-tanzer.at/

Python 3.5::

    3.5.0.final.0 *** latin-1 ***
    From: Christian Tanzer <tanzer at swing.co.at>
    To: Christian Tanzer <tanzer at swing.co.at>
    Content-type: text/plain; charset=utf-8


    Sehr geehrte Damen und Herren,

    ...

    Danke und mit freundlichen Grüssen,

    --
    Christian Tanzer                                    http://www.c-tanzer.at/

In both Python versions, `msg.get_content_charset()` returns None, which is not correct, either.

----------
components: Library (Lib)
files: email_get_payload__test.py
messages: 253994
nosy: tanzer at swing.co.at
priority: normal
severity: normal
status: open
title: email.message.get_payload returns wrong encoding
type: behavior
versions: Python 3.5
Added file: http://bugs.python.org/file40934/email_get_payload__test.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25545>
_______________________________________


More information about the New-bugs-announce mailing list