Skip to content

can't use UTF8 passwords in imaplib login�?#93548

Open
@JulienFS

Description

@JulienFS

Bug report

When trying to login on an imap server thant handles utf8 with an utf8 password, I get an UnicodeEncodeError: 'ascii' codec can't encode character error.

import imaplib
import getpass

host = input('Host: ')
with imaplib.IMAP4_SSL(host) as imap:
    imap.login(input('User: '), getpass.getpass())

I can't enable UTF8 before login as I end up with imaplib.IMAP4.error: command ENABLE illegal in state NONAUTH, only allowed in states AUTH

However things are OK if I add the ENABLE command in NONAUTH state with imaplib.Commands['ENABLE'] = ('NONAUTH', 'AUTH', )

Your environment

  • CPython versions tested on: 3.10.4
  • Operating system and architecture: Linux 5.16.0-4-amd64 Debian testing 5.16.12-1

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.10only security fixes3.11only security fixes3.12only security fixestopic-emailtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions