Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

email.message as_string() not writing unixfrom #88561

Closed
konstantin2 mannequin opened this issue Jun 11, 2021 · 4 comments
Closed

email.message as_string() not writing unixfrom #88561

konstantin2 mannequin opened this issue Jun 11, 2021 · 4 comments
Labels
3.9 only security fixes 3.10 only security fixes 3.11 only security fixes topic-email

Comments

@konstantin2
Copy link
Mannequin

konstantin2 mannequin commented Jun 11, 2021

BPO 44395
Nosy @warsaw, @bitdancer, @corona10, @miss-islington, @FFY00
PRs
  • bpo-44395: Fix MIMEPart.as_string to pass unixfrom properly #26685
  • [3.10] bpo-44395: Fix MIMEPart.as_string to pass unixfrom properly (GH-26685) #26828
  • [3.9] bpo-44395: Fix MIMEPart.as_string to pass unixfrom properly (GH-26685) #26829
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2021-06-21.14:27:56.650>
    created_at = <Date 2021-06-11.14:15:26.350>
    labels = ['3.11', 'expert-email', '3.10', '3.9']
    title = 'email.message as_string() not writing unixfrom'
    updated_at = <Date 2021-06-21.14:27:56.649>
    user = 'https://bugs.python.org/konstantin2'

    bugs.python.org fields:

    activity = <Date 2021-06-21.14:27:56.649>
    actor = 'corona10'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-06-21.14:27:56.650>
    closer = 'corona10'
    components = ['email']
    creation = <Date 2021-06-11.14:15:26.350>
    creator = 'konstantin2'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 44395
    keywords = ['patch']
    message_count = 4.0
    messages = ['395635', '396247', '396248', '396249']
    nosy_count = 6.0
    nosy_names = ['barry', 'r.david.murray', 'corona10', 'miss-islington', 'FFY00', 'konstantin2']
    pr_nums = ['26685', '26828', '26829']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue44395'
    versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

    @konstantin2
    Copy link
    Mannequin Author

    konstantin2 mannequin commented Jun 11, 2021

    When using as_string(unixfrom=True), the "From " line is not always printed. The behaviour is correct for as_bytes().

    Test case:

    ----

    import email.message
    
    msg = email.message.EmailMessage()
    msg.set_payload('Hello World\n')
    msg.set_unixfrom('From foo@bar Thu Jan  1 00:00:00 1970')
    msg['Subject'] = 'Hello'
    msg['From'] = 'Me <me@foo.bar>'
    print('as_string:')
    print(msg.as_string(unixfrom=True))
    print('as_bytes:')
    print(msg.as_bytes(unixfrom=True).decode())

    Results (3.5 and 3.9):

    as_string:
    Subject: Hello
    From: Me <me@foo.bar>

    Hello World

    as_bytes:
    From foo@bar Thu Jan 1 00:00:00 1970
    Subject: Hello
    From: Me <me@foo.bar>

    Hello World

    @konstantin2 konstantin2 mannequin added 3.9 only security fixes topic-email labels Jun 11, 2021
    @corona10 corona10 added 3.10 only security fixes 3.11 only security fixes labels Jun 12, 2021
    @corona10
    Copy link
    Member

    New changeset 30f7a77 by Dong-hee Na in branch 'main':
    bpo-44395: Fix MIMEPart.as_string to pass unixfrom properly (GH-26685)
    30f7a77

    @miss-islington
    Copy link
    Contributor

    New changeset 20a1495 by Miss Islington (bot) in branch '3.10':
    bpo-44395: Fix MIMEPart.as_string to pass unixfrom properly (GH-26685)
    20a1495

    @miss-islington
    Copy link
    Contributor

    New changeset 67b3a99 by Miss Islington (bot) in branch '3.9':
    bpo-44395: Fix MIMEPart.as_string to pass unixfrom properly (GH-26685)
    67b3a99

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.9 only security fixes 3.10 only security fixes 3.11 only security fixes topic-email
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants