Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

As of next week, passwords will be entered in Morse code.


devel / comp.lang.python / Re: imaplib: is this really so unwieldy?

SubjectAuthor
o Re: imaplib: is this really so unwieldy?Chris Angelico

1
Re: imaplib: is this really so unwieldy?

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: rosuav@gmail.com (Chris Angelico)
Newsgroups: comp.lang.python
Subject: Re: imaplib: is this really so unwieldy?
Date: Tue, 25 May 2021 21:46:34 +1000
Lines: 22
Message-ID: <mailman.332.1621943208.3087.python-list@python.org>
References: <21fb6c5f-97a4-654b-887f-2c31a549bcbe@adminart.net>
<YKzFm7gR+5eKzov7@cskk.homeip.net>
<CAPTjJmoEfrfyhP8ct-JoN_T2y8Vh1EMfSyQX+v0CNDFr6WHbbg@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de 6yVBceFTK3+2CBrpZX7ghAO5AqDm+VEzDznQtil6vYRg==
Return-Path: <rosuav@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=FxPjcPIe;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.047
X-Spam-Evidence: '*H*': 0.91; '*S*': 0.00; 'string': 0.05;
'characters,': 0.09; 'choice.': 0.09; 'rfc': 0.09; 'talks': 0.14;
'cameron': 0.16; 'charset': 0.16; 'chrisa': 0.16; 'encoding':
0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16;
'simpson': 0.16; 'specify': 0.16; 'these.': 0.16; 'things,': 0.16;
'wrote:': 0.16; 'tue,': 0.18; 'code.': 0.19; 'to:addr:python-
list': 0.23; 'anything': 0.24; 'section': 0.26; 'text': 0.29;
'but': 0.31; 'expect': 0.31; 'formats': 0.32; 'specified': 0.32;
'to:name:python': 0.32; 'message-id:@mail.gmail.com': 0.33;
'received:209.85.166': 0.33; 'header:In-Reply-To:1': 0.33;
'particular': 0.34; 'received:google.com': 0.34; 'contains': 0.35;
'from:addr:gmail.com': 0.35; 'way': 0.37; 'really': 0.37;
'received:209.85': 0.38; "it's": 0.38; 'received:209': 0.38;
'going': 0.38; 'best': 0.61; 'lot': 0.62; '25,': 0.63; 'outside':
0.63; 'subject:this': 0.63; 'look': 0.66; 'deeply': 0.69; '2021':
0.84; 'conservative': 0.84; 'decode': 0.84; 'method:': 0.84;
'quotes,': 0.84; 'range,': 0.84; 'subject:really': 0.84; 'that:':
0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to;
bh=bf/9uBGQE3qFjP4eoJFNSiYsoKQFh1s7+sAgj8hJ+ak=;
b=FxPjcPIecJA0TkoarInjSSmsQ2wwk97nBtO8VyUlE1WD6E9FXD28LYnEbLSmCAQE+i
VwTH1yDJgt5id4cWXRULLzGViZEituqol8Drs1RsBokx5H9ibyjkseTQs1ed103XNY9/
+4//izftCEf+pl3p6qZNyAx0ifUWnjTUJxyBXP6OIqepVuUlFV2rxJqFUJWAkW6nDZ0K
tDi6lp+02KoqaIFQMLi3BvkYI/dOigCvGAXwHqQr0/Deku5qnNLLWCSK9lv4Ph617XC+
PildYMU1BVHgtqcSu+wSrEH8a4+q0KWHjNBjtFa3WoRUvA6G/W5rpw267DbhkVqPP56l
eVqA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20161025;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to;
bh=bf/9uBGQE3qFjP4eoJFNSiYsoKQFh1s7+sAgj8hJ+ak=;
b=oWr4CzuCHDzv+epnI9kz+BvcZSNy85Q0XXvNM79uMAKdWYKr+KT3h6q98tuwzT3hRm
eiI7O+RHfyV1EE0BBOsKy0qI0Afg1dYhJxJpbwsLHj3kF3zm9oLID7ea7iPJuWbhlc05
Dbm3pfswRdvuB7DtKpiiULtfk9IJifziIjeJA+pQ6SnqHd+2ZFRmz8PCC6FrdfP2xrMS
CDWqBbGCsRJMksrHr2vsSvgWzf2FPUFtoBJCeirDUP0YRFs+jCEbRNId4+qYpIuFyFi8
UP/zGsfalOGvTa23cDZvfQdwefpvzSe+fEmomDjueI71skagv8zEgboSqXNt1Rcxf3lm
mkPA==
X-Gm-Message-State: AOAM532LCeq+L7SOcTRcMuEWcUDe9pJVzMsOh439jkfLXYn2xp44Bymf
lxt3A9Da+d30GSxgBZNV1lvxpYATnPvcvahs5sVh1IVdO0I=
X-Google-Smtp-Source: ABdhPJwp0/sfh9MnJAsRwDmobTt3pqpoDx0jBkuLwt7m2vTrT1WnOW7NN+pLIbZuuQTu3rb3gqtPQ6in6uEtzNDBEMA=
X-Received: by 2002:a92:cb12:: with SMTP id s18mr21520160ilo.297.1621943205715;
Tue, 25 May 2021 04:46:45 -0700 (PDT)
In-Reply-To: <YKzFm7gR+5eKzov7@cskk.homeip.net>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.34
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: <CAPTjJmoEfrfyhP8ct-JoN_T2y8Vh1EMfSyQX+v0CNDFr6WHbbg@mail.gmail.com>
X-Mailman-Original-References: <21fb6c5f-97a4-654b-887f-2c31a549bcbe@adminart.net>
<YKzFm7gR+5eKzov7@cskk.homeip.net>
 by: Chris Angelico - Tue, 25 May 2021 11:46 UTC

On Tue, May 25, 2021 at 8:21 PM Cameron Simpson <cs@cskk.id.au> wrote:
> When you go:
>
> text = str(data)
>
> that is _assuming_ a particular text encoding stored in the data. You
> really ought to specify an encoding here. If you've not specified the
> CHARSET for things, 'ascii' would be a conservative choice. The IMAP RFC
> talks about what to expect in section 4 (Data Formats). There's quite a
> lot of possible response formats and I can understand imaplib not
> getting deeply into decoding these.

Worse than that: what you actually get is the repr of the bytes. That
might happen to look a lot like an ASCII decode, but if the string
contains unprintable characters, quotes, or anything outside of the
ASCII range, it's going to represent it as an escape code.

The best way to turn bytes into text is the decode method:

data.decode("UTF-8")

ChrisA


devel / comp.lang.python / Re: imaplib: is this really so unwieldy?

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor