question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Redundant cc code in email.py?

See original GitHub issue

Describe the bug I’m doing some work on helpdesk/email.py for a fork of Helpdesk. I noticed that the work done in lines 507-516 don’t seem to have any effect, and when run, the block doesn’t parse the emails from message.get_all('cc', None) properly in one case.

The block seems to be leftover from some rework commits, since the variable cc isn’t used elsewhere; later on, the line 360 creates a list of addresses correctly and in fewer lines.

Is there a reason for this code block to be here? Or can I remove it without issue?

To Reproduce Here’s a reproduction based on one email I imported. For this email, on line 507, message.get_all('cc', None) produces this list of length 1 (I’ve randomized the names/domain):

[
    '"Brunet, Angelus (ABC)" <Angelus.Brunet@abc.com>, "Durant, Lawrence ABC)"\r\n\t<Durant.Lawrence@abc.com>, "Abrami, Henri (ABC)" <henri.abrami@abc.com>, \r\n\t"Barta, Kai (ABC)" <Kai.Barta@abc.com>'
]

Using that value for cc, and replacing line 510’s message.get_charset() with None, the final result on line 516 splits on the commas inside the names, and it doesn’t strip \r\n\t from one of the strings.

{
    '"Barta',
    'Kai (ABC)" <Kai.Barta@abc.com>',
    '"Durant', 
    'Angelus (ABC)" <Angelus.Brunet@abc.com>',
    '"Abrami',
    'Henri (ABC)" <henri.abrami@abc.com>',
    '"Brunet',
    'Lawrence ABC)"\r\n\t<Durant.Lawrence@abc.com>'
}

Expected behavior I would expect the block to instead produce the following:

{
    '"Barta, Kai (ABC)" <Kai.Barta@abc.com>', 
    '"Brunet, Angelus (ABC)" <Angelus.Brunet@abc.com>', 
    '"Abrami, Henri (ABC)" <henri.abrami@abc.com>',
    '"Durant, Lawrence (ABC)" <Lawrence.Durant@abc.com>'
}

Additional context My fork of email.py is up to date with the latest commit in the master branch. I’m debugging email.py locally, by running ./manage.py get_email with a real email address using IMAP.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ebeers-pngcommented, Sep 20, 2021

Thanks, I’ll take it out of my fork then!

I’ll try to submit a PR after I finish working on the file! I’ve cleaned up some other little importing bugs for my fork that I’m sure would be useful to the master branch 😃

0reactions
gwassercommented, Jul 22, 2022

This was cleaned up for our next release (0.5), check out the unstable branch.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python Gmail BCC and CC [duplicate] - Stack Overflow
So, i have made this Python code that sends an email using a gmail account and i dont know how to add a...
Read more >
Same email address in both to and CC fields - CodeProject
I've added an email address in both TO and CC fields(same email in both textboxes). The recipient is getting two emails.
Read more >
Hiding BCC Recipients In Python MIME Emails - PyBites
The workaround I've found that works for me is to completely omit my list of recipients from the MIME header information altogether and...
Read more >
Is redundant condition checking against best practices?
What you are asking for is called "robustness", and there is no right or wrong answer. It depends on the size and complexity...
Read more >
Python Tutorial - Getting Started with Python and Python Basics
A single line of Python code can do many lines of code in traditional general-purpose languages (such as C/C++/Java). Python is free and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found