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

MIMEMultipart _subparts constructor unusable #39866

Closed
amitar mannequin opened this issue Jan 25, 2004 · 3 comments
Closed

MIMEMultipart _subparts constructor unusable #39866

amitar mannequin opened this issue Jan 25, 2004 · 3 comments
Assignees
Labels
stdlib Python modules in the Lib dir

Comments

@amitar
Copy link
Mannequin

amitar mannequin commented Jan 25, 2004

BPO 884030
Nosy @warsaw
Files
  • MIMEMultipart_2.3.3.diff: suggested fix (diff 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 = 'https://github.com/warsaw'
    closed_at = <Date 2004-05-09.18:01:16.000>
    created_at = <Date 2004-01-25.07:19:42.000>
    labels = ['library']
    title = 'MIMEMultipart _subparts constructor unusable'
    updated_at = <Date 2004-05-09.18:01:16.000>
    user = 'https://bugs.python.org/amitar'

    bugs.python.org fields:

    activity = <Date 2004-05-09.18:01:16.000>
    actor = 'barry'
    assignee = 'barry'
    closed = True
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2004-01-25.07:19:42.000>
    creator = 'amitar'
    dependencies = []
    files = ['1187']
    hgrepos = []
    issue_num = 884030
    keywords = []
    message_count = 3.0
    messages = ['19819', '19820', '19821']
    nosy_count = 2.0
    nosy_names = ['barry', 'amitar']
    pr_nums = []
    priority = 'normal'
    resolution = 'accepted'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue884030'
    versions = []

    @amitar
    Copy link
    Mannequin Author

    amitar mannequin commented Jan 25, 2004

    It is not clear how to pass initial list of messages to
    MIMEMultipart.
    From doc it seems that _subparts should be a single
    list-like object, from source it seems that it expects
    seperate parameters - neither work...

    My suggested patch implemets the single parameter way
    (after applying it, the second try in the example below
    does work).

    ((to apply the patch, use :
    cp MIMEMultipart.py MIMEMultipart_orig.py
    patch -i MIMEMultipart_2.3.3.diff -o MIMEMultipart.py
    MIMEMultipart_orig.py
    ))

    example:

    >>> msgs = [MIMEText('a'),MIMEText('b')]
    >>> MIMEMultipart('mixed',None,msgs[0],msgs[1])
    Traceback (most recent call last):
      File "<stdin>", line 1, in ?
      File "/usr/lib/python2.3/email/MIMEMultipart.py",
    line 35, in __init__
        self.attach(*list(_subparts))
    TypeError: attach() takes exactly 2 arguments (3 given)
    >>> MIMEMultipart('mixed',None,msgs).as_string() 
    Traceback (most recent call last):
      File "<stdin>", line 1, in ?
      File "/usr/lib/python2.3/email/Message.py", line 130,
    in as_string
        g.flatten(self, unixfrom=unixfrom)
      File "/usr/lib/python2.3/email/Generator.py", line
    102, in flatten
        self._write(msg)
      File "/usr/lib/python2.3/email/Generator.py", line
    130, in _write
        self._dispatch(msg)
      File "/usr/lib/python2.3/email/Generator.py", line
    156, in _dispatch
        meth(msg)
      File "/usr/lib/python2.3/email/Generator.py", line
    230, in _handle_multipart
        g.flatten(part, unixfrom=False)
      File "/usr/lib/python2.3/email/Generator.py", line
    102, in flatten
        self._write(msg)
      File "/usr/lib/python2.3/email/Generator.py", line
    130, in _write
        self._dispatch(msg)
      File "/usr/lib/python2.3/email/Generator.py", line
    147, in _dispatch
        main = msg.get_content_maintype()
    AttributeError: 'list' object has no attribute
    'get_content_maintype'
    >>>

    @amitar amitar mannequin closed this as completed Jan 25, 2004
    @amitar amitar mannequin assigned warsaw Jan 25, 2004
    @amitar amitar mannequin added the stdlib Python modules in the Lib dir label Jan 25, 2004
    @amitar amitar mannequin closed this as completed Jan 25, 2004
    @amitar amitar mannequin assigned warsaw Jan 25, 2004
    @amitar amitar mannequin added the stdlib Python modules in the Lib dir label Jan 25, 2004
    @amitar
    Copy link
    Mannequin Author

    amitar mannequin commented Jan 25, 2004

    Logged In: YES
    user_id=564711

    This refers to the email package...

    To my example I should have added at the beginning:

    >> from email.MIMEText import MIMEText
    >> from email.MIMEMultipart import MIMEMultipart

    @warsaw
    Copy link
    Member

    warsaw commented May 9, 2004

    Logged In: YES
    user_id=12800

    Your patch seems right since it implements what's
    documented. I'll apply this for Python 2.3.4 and Python 2.4
    (with a bit of reformatting and a test case).

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant