[issue12537] mailbox's _become_message is very fragile
David Lam d...@dlam.me added the comment: Wow, cool! Thanks for the update. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12537 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12537] mailbox's _become_message is very fragile
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset 5c1c402a63e5 by R David Murray in branch 'default': #12537: in mailbox avoid depending on knowledge of email package internals http://hg.python.org/cpython/rev/5c1c402a63e5 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12537 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12537] mailbox's _become_message is very fragile
R. David Murray rdmur...@bitdance.com added the comment: David, thanks for your assistance. I didn't wind up using your patch, but the work you did was valuable in preparing the patch I committed. What I did was turn your 'detect the attributes' recipe into a unit test. I then applied your patch, but it didn't quite work. I eventually figured out that the fix I suggested wasn't quite right, that in fact the right place to delete the attributes is in _become_message. So I moved the list of attributes you developed in your patch into class attributes, so that what the final patch does is to copy everything *except* the attributes you found. So, a successful resolution, thank you. -- resolution: - fixed stage: - committed/rejected status: open - closed type: - behavior ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12537 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12537] mailbox's _become_message is very fragile
David Lam d...@dlam.me added the comment: This patch deletes the leftover special attributes. Thanks for guiding me through my confusion and/or cluelessness! -- keywords: +patch Added file: http://bugs.python.org/file23191/12537.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12537 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12537] mailbox's _become_message is very fragile
Changes by David Lam d...@dlam.me: Added file: http://bugs.python.org/file23192/12537.find.attribute.differences.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12537 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12537] mailbox's _become_message is very fragile
R. David Murray rdmur...@bitdance.com added the comment: Unfortunately I don't think there is any way except going through each subclass to see what special attributes it creates. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12537 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12537] mailbox's _become_message is very fragile
David Lam d...@dlam.me added the comment: Hm, it seems right now that the only time that happens is when creating a message based on an mbox message. The 'status' and 'x-status' attributes are deleted. Any hints on what I could to do figure out what special attributes should be deleted? I was thinking I might try to find and go through the mailbox specs, and find out what headers are mandatory for each of them. I think I see some hints on... http://docs.python.org/library/mailbox.html#mailbox.mboxMessage. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12537 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12537] mailbox's _become_message is very fragile
David Lam d...@dlam.me added the comment: Hi hi, noob here. I found this today after clicking 'Easy issues' link. Would something like this work? test_mailbox.py seems to pass. However, I'm not too sure what more needs to be done in the _explain_to. It seems like everything to convert headers/flags between message formats are already there ? diff -r 63bf3bae20ef Lib/mailbox.py --- a/Lib/mailbox.pyWed Sep 14 11:46:17 2011 -0400 +++ b/Lib/mailbox.pyWed Sep 14 17:12:51 2011 -0700 @@ -1467,8 +1467,7 @@ def _become_message(self, message): Assume the non-format-specific state of message. -for name in ('_headers', '_unixfrom', '_payload', '_charset', - 'preamble', 'epilogue', 'defects', '_default_type'): +for name in message.__dict__: self.__dict__[name] = message.__dict__[name] -- nosy: +dlam ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12537 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12537] mailbox's _become_message is very fragile
R. David Murray rdmur...@bitdance.com added the comment: That is the first step, yes. In addition to that we need to have the various explain_to methods delete the special attributes that aren't valid for the new Message subtype. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12537 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12537] mailbox's _become_message is very fragile
Changes by Justin Wehnes jweh...@gmail.com: -- nosy: +jwehnes ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12537 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12537] mailbox's _become_message is very fragile
Changes by Kasun Herath kasun...@gmail.com: -- nosy: +kasun ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12537 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12537] mailbox's _become_message is very fragile
New submission from R. David Murray rdmur...@bitdance.com: The mailbox module has a method _become_message that copies attributes from an object that is an email.message.Message subclass to the calling object (which is also a subclass of email.message.Message). This method is very fragile in the face of any changes to the email.message.Message attribute set. Instead it would be better to decouple the mailbox and email modules by copying *all* __dict__ attributes from the source message to the new object, and then rewrite the _explain_to methods to not only convert the 'special attributes' to the correct format for the new subclass, but also delete any leftover special attributes. -- components: Library (Lib) keywords: easy messages: 140157 nosy: r.david.murray priority: normal severity: normal status: open title: mailbox's _become_message is very fragile versions: Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12537 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12537] mailbox's _become_message is very fragile
Changes by Thomas Holmes tho...@devminded.com: -- nosy: +thomas.holmes ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12537 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12537] mailbox's _become_message is very fragile
José María Ruiz Aguilera josemariar...@gmail.com added the comment: Hi, I will be working on this issue. This is the first time I will work on a issue in Python so please patient. -- nosy: +josemaria ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12537 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com