Skip to content

Not all defects pass through email policy #68552

Closed

Description

@bitdancer
BPO 24364
Nosy @warsaw, @bitdancer, @vadmium, @MaxwellDupre
Files
  • defect-fixes.patch
  • defect-fixes.v2.patch
  • 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 = None
    created_at = <Date 2015-06-02.16:39:13.083>
    labels = ['easy', 'type-bug', 'expert-email']
    title = 'Not all defects pass through email policy'
    updated_at = <Date 2021-12-24.13:12:22.924>
    user = 'https://github.com/bitdancer'

    bugs.python.org fields:

    activity = <Date 2021-12-24.13:12:22.924>
    actor = 'mikecmcleod'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['email']
    creation = <Date 2015-06-02.16:39:13.083>
    creator = 'r.david.murray'
    dependencies = []
    files = ['43486', '43533']
    hgrepos = []
    issue_num = 24364
    keywords = ['patch', 'easy']
    message_count = 7.0
    messages = ['244679', '268642', '268895', '268987', '269224', '269257', '409142']
    nosy_count = 4.0
    nosy_names = ['barry', 'r.david.murray', 'martin.panter', 'mikecmcleod']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue24364'
    versions = ['Python 3.5', 'Python 3.6']

    Linked PRs

    Activity

    1. bitdancer commented on Jun 2, 2015

      @bitdancer
      MemberAuthor

      This is a note to myself. While looking at another issue I noticed that I never completed the work to make sure that all message defects discovered by feedparser are passed through the policy defect handler. The fix is simple, the time consuming part is writing the tests.

    2. vadmium commented on Jun 16, 2016

      @vadmium
      Member

      In particular, I noticed InvalidHeaderDefect is not raised if a header line begins with a colon (:), and also MisplacedEnvelopeHeaderDefect, if a header line begins "From ", including a space, and is neither the first or last line of the header section.

    3. vadmium commented on Jun 20, 2016

      @vadmium
      Member

      Here is a patch to fix the two defects in Lib/email/feedparser.py. I also made some extra changes to the tests:

      • Remove some tests from Lib/test/test_email/test_email.py, because I think they were redundant with methods of the same name in test_defect_handling.py.

      • Change a couple of the tests in test_defect_handling.py to verify there are no defects recorded at all even in raise_on_defect=True mode.

    4. bitdancer commented on Jun 21, 2016

      @bitdancer
      MemberAuthor

      test_email/test_email tests the compat32 policy. test_defect_handling tests the default policy. Thus they are not redundant, except of course that they are...it would be better to run the same test with both policies in turn, but I never got as far as setting up that infrastructure.

      That said, for defects it may not matter, and for the other "redudant" tests sometimes the result is different, which is the point of the new policy. So, things are in a bit of a limbo currently and could use some sorting out. You'll note that in some cases in test_email I've noted where the corresponding test for the new policy is in the new test files. There are a bunch more tests in test_email that need equivalents for the new policies (and I'm sure we'll find some bugs when that happens, unfortunately).

    5. vadmium commented on Jun 25, 2016

      @vadmium
      Member

      I see that “compat32” and “default” are actually different things (Compat32 vs EmailPolicy classes). IMO “default” was a bad choice of name, but I guess that ship has already sailed.

      This patch adds a test_defect_handling.TestCompat32 subclass, so the test methods are now run with compat32 as well as the “default” policy.

    6. bitdancer commented on Jun 25, 2016

      @bitdancer
      MemberAuthor

      The name default is future proofing. It will be the default...eventually :) And it is the default now if you use EmailMessage to construct your messages.

    7. MaxwellDupre commented on Dec 24, 2021

      MaxwellDupremannequin
    8. transferred this issue fromon Apr 10, 2022
    9. added
      stdlibStandard Library Python modules in the Lib/ directory
      on Nov 23, 2023
    10. Yuheng3107 commented on Jul 29, 2025

      @Yuheng3107
      Contributor

      Is this issue still open to contributions?

    11. added a commit that references this issue on Dec 6, 2025
    12. bitdancer commented on Dec 6, 2025

      @bitdancer
      MemberAuthor

      Thanks for taking care of this long overdue issue.

    13. added 2 commits that reference this issue on Dec 6, 2025
    14. added 2 commits that reference this issue on Dec 9, 2025
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      easystdlibStandard Library Python modules in the Lib/ directorytopic-emailtype-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions