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 <tan...@swing.co.at>
    To: Christian Tanzer <tan...@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 <tan...@swing.co.at>
    To: Christian Tanzer <tan...@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: tan...@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 <rep...@bugs.python.org>
<http://bugs.python.org/issue25545>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to