Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

New crypt. See /usr/news/crypt.


devel / comp.lang.python / Re: email.message_from_file & quoted printable

SubjectAuthor
o Re: email.message_from_file & quoted printableCameron Simpson

1
Re: email.message_from_file & quoted printable

<mailman.19.1640300123.3079.python-list@python.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=20889&group=comp.lang.python#20889

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: cs@cskk.id.au (Cameron Simpson)
Newsgroups: comp.lang.python
Subject: Re: email.message_from_file & quoted printable
Date: Fri, 24 Dec 2021 09:55:14 +1100
Lines: 35
Message-ID: <mailman.19.1640300123.3079.python-list@python.org>
References: <CANc-5UyPuqb3vN5czu5RE=wb1jm=voah6yg89U1qkWfGOHHJVQ@mail.gmail.com>
<YcT+Unu8ytexrRiN@cskk.homeip.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de W4dFuCza0kcbrG7IkS9H1g8FyrecG3XfwjTbkUDgdufg==
Return-Path: <cameron@cskk.id.au>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.003
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'bunch': 0.05; 'string':
0.07; 'archives': 0.09; 'text.': 0.09; 'cheers,': 0.11; '>>>>':
0.16; 'cameron': 0.16; 'encoding.': 0.16; 'false.': 0.16; 'flag':
0.16; 'from:addr:cs': 0.16; 'from:addr:cskk.id.au': 0.16;
'from:name:cameron simpson': 0.16; 'message-id:@cskk.homeip.net':
0.16; 'montanaro': 0.16; 'received:13.237': 0.16;
'received:13.237.201': 0.16; 'received:13.237.201.189': 0.16;
'received:cskk.id.au': 0.16; 'received:id.au': 0.16;
'received:mail.cskk.id.au': 0.16; 'simpson': 0.16; 'skip:> 20':
0.16; 'things,': 0.16; 'wrote:': 0.16; 'to:addr:python-list':
0.20; 'seems': 0.26; 'space': 0.26; 'old': 0.27; 'example,': 0.28;
'header:User-Agent:1': 0.30; 'objects': 0.32; 'to:name:python':
0.32; 'but': 0.32; "i'm": 0.33; 'package': 0.34; 'header:In-Reply-
To:1': 0.34; 'received:au': 0.35; 'files': 0.36; 'using': 0.37;
"it's": 0.37; 'could': 0.38; 'read': 0.38; 'list': 0.39; 'use':
0.39; '(with': 0.39; 'still': 0.40; 'try': 0.40; 'should': 0.40;
'true': 0.63; 'email': 0.63; 'received:13': 0.64;
'received:userid': 0.66; 'transfer': 0.69; 'above,': 0.70;
'decode': 0.84; 'retains': 0.84; 'subject:skip:e 20': 0.84
Mail-Followup-To: Python <python-list@python.org>
Content-Disposition: inline
In-Reply-To: <CANc-5UyPuqb3vN5czu5RE=wb1jm=voah6yg89U1qkWfGOHHJVQ@mail.gmail.com>
User-Agent: Mutt/2.1.4 (2021-12-11)
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <YcT+Unu8ytexrRiN@cskk.homeip.net>
X-Mailman-Original-References: <CANc-5UyPuqb3vN5czu5RE=wb1jm=voah6yg89U1qkWfGOHHJVQ@mail.gmail.com>
 by: Cameron Simpson - Thu, 23 Dec 2021 22:55 UTC

On 23Dec2021 14:50, Skip Montanaro <skip.montanaro@gmail.com> wrote:
>I have a bunch of old email archives I'm messing around with, for example,
>rendering them on-demand in HTML. Some of the files use quoted printable
>content transfer encoding. Here's one (with a number of headers elided):
[...]
>This message is stored in a file. I read it using
>email.message_from_file.
>In the example above, the payload still retains the quoted printable bits.
>Maybe it's not correctly encoded (no "=20" at the end of the second
>paragraph, for example)

That seems legit, as it is a space in the message text.

>, but I would have thought the email package would
>do what it could to decode things, but nope:
>
>>>> print(msg.get_payload())

From the docs:

get_payload(i=None, decode=False)

Return the current payload, which will be a list of Message
objects when is_multipart() is True, or a string when is_multipart()
is False. [...]
Optional decode is a flag indicating whether the payload should
be decoded or not, according to the Content-Transfer-Encoding
header. When True and the message is not a multipart, the payload
will be decoded if this header’s value is quoted-printable or
base64.

Try decode=True.

Cheers,
Cameron Simpson <cs@cskk.id.au>


devel / comp.lang.python / Re: email.message_from_file & quoted printable

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor