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

Message's To Field Behaves Differently with List or Tuple #70

Open
jplehmann opened this issue Nov 11, 2016 · 0 comments
Open

Message's To Field Behaves Differently with List or Tuple #70

jplehmann opened this issue Nov 11, 2016 · 0 comments
Labels
1.bug An error has been encountered that is preventing utilization. area:message Issue relates to the MIME e-mail Message object representation. org:good-first-issue Good for newcomers to the project to tackle.

Comments

@jplehmann
Copy link

jplehmann commented Nov 11, 2016

If you try to be immutable, it doesn't like you.

Works fine.

In [4]: Message(author="nlp1.noreply@lexmachina.com", to=["jlehmann@lexmachina.com"])
Out[4]: <marrow.mailer.message.Message at 0x7fe136bd3590>

Dies horribly. Seems to go down a different code path and expects a 2-tuple of name and email. But that wasn't what was intended at all -- should just be a list of emails.

In [5]: Message(author="nlp1.noreply@lexmachina.com", to=("jlehmann@lexmachina.com",))
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-5-a713a363d72b> in <module>()
----> 1 Message(author="nlp1.noreply@lexmachina.com", to=("jlehmann@lexmachina.com",))

/home/lex/local/lib/python2.7/site-packages/marrow/mailer/message.pyc in __init__(self, author, to, subject, **kw)
     86 
     87                 if to is not None:
---> 88                         self.to = to
     89 
     90                 if subject is not None:

/home/lex/local/lib/python2.7/site-packages/marrow/mailer/message.pyc in __setattr__(self, name, value)
     99         def __setattr__(self, name, value):
    100                 """Set the dirty flag as properties are updated."""
--> 101                 object.__setattr__(self, name, value)
    102                 if name not in ('bcc', '_id', '_dirty', '_processed'):
    103                         object.__setattr__(self, '_dirty', True)

/home/lex/local/lib/python2.7/site-packages/marrow/mailer/address.pyc in __set__(self, instance, value)
    220         def __set__(self, instance, value):
    221                 if not isinstance(value, self.cls):
--> 222                         value = self.cls(value)
    223 
    224                 setattr(instance, self.attr, value)

/home/lex/local/lib/python2.7/site-packages/marrow/mailer/address.pyc in __init__(self, addresses, encoding)
    137 
    138                 elif isinstance(addresses, tuple):
--> 139                         self.append(Address(addresses, encoding=encoding))
    140                         return
    141 

/home/lex/local/lib/python2.7/site-packages/marrow/mailer/address.pyc in __init__(self, name_or_email, email, encoding)
     37                         if isinstance(name_or_email, (tuple, list)):
     38                                 self.name = unicodestr(name_or_email[0], encoding)
---> 39                                 self.address = unicodestr(name_or_email[1], encoding)
     40 
     41                         elif isinstance(name_or_email, bytes):

IndexError: tuple index out of range

Versions:

$ pip freeze | grep marrow
marrow.interface==1.0.1
marrow.mailer==4.0.1
marrow.util==1.2.3
pyramid-marrowmailer==0.1
@amcgregor amcgregor added 1.bug An error has been encountered that is preventing utilization. area:message Issue relates to the MIME e-mail Message object representation. org:good-first-issue Good for newcomers to the project to tackle. labels Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.bug An error has been encountered that is preventing utilization. area:message Issue relates to the MIME e-mail Message object representation. org:good-first-issue Good for newcomers to the project to tackle.
Projects
None yet
Development

No branches or pull requests

2 participants